New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refresh OAuth2 access tokens by default in the OAuthSwiftClient #217
Comments
…n NSError to detect whether it was caused by an invalid access token
… OAuthSwiftClient Created a tokenExpirationHandler on OAuthSwiftClient to enable the OAuth2Swift class to configure the client to handle expired access tokens.
…roperty on OAuthSwiftClient to get informed about access token renewals Build as a replacement for the optional callback parameter on the deprecated convenience method in OAuth2Swift.
…n NSError to detect whether it was caused by an invalid access token
… OAuthSwiftClient Created a tokenExpirationHandler on OAuthSwiftClient to enable the OAuth2Swift class to configure the client to handle expired access tokens.
…roperty on OAuthSwiftClient to get informed about access token renewals Build as a replacement for the optional callback parameter on the deprecated convenience method in OAuth2Swift.
…tion for Facebooks API
…tionHandler which now has an assert to not use it for OAuth1
…n NSError to detect whether it was caused by an invalid access token
… OAuthSwiftClient Created a tokenExpirationHandler on OAuthSwiftClient to enable the OAuth2Swift class to configure the client to handle expired access tokens.
…roperty on OAuthSwiftClient to get informed about access token renewals Build as a replacement for the optional callback parameter on the deprecated convenience method in OAuth2Swift.
…tion for Facebooks API
…tionHandler which now has an assert to not use it for OAuth1
I am trying to get this to work with Meetup.com and it seems that the access token is correctly set in line 83 of authorizeWithCallbackURL but you are not storing the "expires_in" responseParameter. Also, I can find no trace of any possible use of "grant type=refresh-token" and requestOAuthAccessTokenWithParameters on line 160 is never being called. For reference, the Meetup Spec is here: http://www.meetup.com/meetup_api/auth/#oauth2server-auth-success Am I doing something wrong or is this a bug? It does seem that the token is correct and signing of requests works properly....just no handling of the refresh |
I think the solution may just be to store the "expires_in" at the same time that you store the token. Inserting these lines: 85, 86 and 87. |
I assume you're using the current version on master, right? The expires in value is actually stored in the To have this automatic refresh token renewal you need to use the special method |
Yes - I am on Master latest version. I use oauthswift.authorizeWithCallbackURL(
(successfully) to get an access token which works....but I see that I then use oauthswift.startAuthorizedRequest(requiredURL, method: .GET, parameters:... to (successfully) sign requests and fetch data...and this works for one Thanks for your help...! Roger Price On Wed, May 4, 2016 at 7:54 PM, Florian Gößler notifications@github.com
|
Problem solved.
I had copied the code from the Documentation page which uses "responseType
= "token" in the initialisation of the oauthswift object.
I went back and modified your demo application to add Meetup.com and it
worked perfectly. Then I noticed that you need to use "responseType =
"code" to get your initial token properly. This causes the flow to work
properly and the refresh token and expiry times come back and do get stored
properly.
Hope I did not cause too much trouble and this clarification may help
others.
Roger Price
|
The PR #596 proposes a solution:
|
Added in #596 |
@fabiomassimo created a convenience method on
OAuth2Swift
to automatically refresh the access token in case of a failure for a normal request in #209 which is nice 👍.I expected this to be the default behaviour of every request made via the
OAuthSwiftClient
, which seems not to be the case right now.My suggestion:
OAuthSwiftClient
and only execute it for OAuth2 requests.OAuthSwiftCredential
of the client.OAuth2Swift
I would either move them as well, move them to an extension ofOAuthSwiftClient
in theOAuth2Swift
file or transform them to class methods. What is the preferred solution?OAuth2Swift
as deprecated and let it just call through to the client. Or even remove the convenience method since no release was made since the introduction of the method and therefore no consumer of this library should be affected.Any thoughts, comments, considerations, suggestions, ...?
I would start working on a PR then. 😉
The text was updated successfully, but these errors were encountered: