Skip to content
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

Refreshing the access token. #38

Closed
oliverfoggin opened this issue Sep 6, 2012 · 5 comments
Closed

Refreshing the access token. #38

oliverfoggin opened this issue Sep 6, 2012 · 5 comments

Comments

@oliverfoggin
Copy link

Hi,

I'm writing an iOS app using this framework (installed through CocoaPods which is brilliant!)

I'm using the username/password flow and it works with no problems when the access_token is still valid.

I'm running the requests using [NXOAuth2Request performMethod:...] and I've followed through to see that this has built in token refreshing in it (i.e. if the token isn't valid it will try to refresh and try the connection again).

However, this isn't working for me all the time.

I've got the requests in an operation queue and I get a 401 error back. (Once the access token expires)

If I then restart the synchronisation process it will try to send the oauth refresh first. and then carry on with the sync.

Is this something that is know? I'm about to go code trawling to see if I can find the cause of this.

Thanks

@oliverfoggin
Copy link
Author

Ah, I just found a section of code commented out with the reason...

TODO: check for status code once the bug returning 500 is fixed

Could you possibly shed some light on this? Thanks

@toto
Copy link
Contributor

toto commented Sep 6, 2012

Can you tell me which services you are using OAuth? Some services (e.g. Yammer, Google) serve the refresh token in wired ways, so that it will not be parsed correctly.

I usually overload the access token parser via a category in that case. Here is an example that works for Yammer

@oliverfoggin
Copy link
Author

The OAuth service is an in house one.

I've just found the problem.

In the section I mentioned above...

  • (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)theResponse;

in

NXOAuth2Connection

The authenticationHeader was null as I wasn't getting back the 401 error reason (expired_token) from the server.

We are now writing that into the return error so hopefully this should be resolved.

If it doesn't fix it I'll let you know.

Thanks for the reply.

Oliver

@stigi
Copy link
Collaborator

stigi commented Sep 6, 2012

@ojfoggin Also please let us know if it does fix it ;)

@oliverfoggin
Copy link
Author

Hi again,

Yes, that worked perfectly.

Thanks

Although, I have found something else that didn't quite work but I'll add a new issue for this as it's not really related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants