nxtbgthng / OAuth2Client

Client library for OAuth2 (currently built against draft 10 of the OAuth2 spec)
855 stars 217 forks source link

refresh access token failing #207

Closed Sravanik84 closed 8 years ago

Sravanik84 commented 8 years ago

Hi Team,

I have an issue with refreshing access token. Here is the list of steps followed to request access token.

  1. Initialize NXOauth2Client
  2. register for 2 notifications: NXOAuth2AccountStoreAccountsDidChangeNotification, NXOAuth2AccountStoreDidFailToRequestAccessNotification
  3. Request access token with username & password.
  4. received access token and refresh token
  5. use "performmethod" of NXOAuth2Request, to get data from the api through a signed request.
  6. And "performmethod", refreshes the access token if it's expired.

This flow seems to be working fine, and some time later the perform method is failing with the below error.

oauthConnection Error: {"error":"invalid_grant","error_description":"Provided Authorization Grant is invalid"}

Assuming that refreshing access token is failing, Issues: my app is not getting any kind of notification back from the NXOAuth2Store regarding the fail.

Neither in the notifications registered above nor in the delegate call back in the "performmethod"

Am i missing something?

  1. I have also registered another observer for the notification, NXOAuth2AccountStoreDidFailToRequestAccessNotification and still didn't get any call back from the OAuthStore.

Can you provide some suggestions.

Thanks,

Sravanik84 commented 8 years ago

solved the issue.

  1. the notification should be NXOAuth2AccountDidFailToGetAccessTokenNotification
  2. and the above notification should be for Account object(NXOAuth2Account), not for Store(NXOAuth2AccountStore)