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

Access token not refreshed #490

Closed
jojo91 opened this issue Nov 25, 2019 · 9 comments
Closed

Access token not refreshed #490

jojo91 opened this issue Nov 25, 2019 · 9 comments
Labels
provider-bug Issues that are affected by bugs or spec non-compliance by an OAuth2 AS / OIDC IDP

Comments

@jojo91
Copy link

jojo91 commented Nov 25, 2019

Hi,

I have an issue when using the method performActionWithFreshTokens.

How to reproduce :

  1. Just login with your login and password natively (not with a webview, with OIDAuthorizationService.perform(tokenRequest))
  2. Save the OIDAuthState object in your local data (userDefaults, core data, realm, whatever)
  3. Wait until the expiration date of your access token is passed
  4. Call the method performActionWithFreshTokens

What happened :

  • The access token is not refreshed, it still is the same as the first one.
  • The token expiration date is nil (don't know why).
  • The refresh token is still valid.

What should happened :

  • The access token is refreshed, different as the old one.
  • The token expiration date is not nil and in a future date.

Note :
It seems that the expiration date is the issue here. I don't know why but the AppAuth library doesn't get the expiration date. Do Anyone knows why ?

  • OS: iOS 13
  • Browser: Native
  • Version: 0.1.6
@WilliamDenniss
Copy link
Member

I don't think we have enough information here to reproduce.

Can you reproduce this using the included examples?
Can you provide a test-case?

@jojo91
Copy link
Author

jojo91 commented Nov 28, 2019

So I have searched a little bit and the issue comes from the dateSinceNowConversion method.
It returns a date only if you have a number in the fields "expires_in" in your jwt token.
In my case, I have a string so the expiration date was never returned.

@WilliamDenniss, why don't you use the field "exp" from the access token ?

@julienbodet
Copy link
Collaborator

julienbodet commented Nov 30, 2019

AppAuth checks for expires_in field in the token response to set the accessTokenExpirationDate. exp field is part of the ID Token.

I believe the issue comes from your provider which returns the expires_in field as a string instead of a number. RFC6749 section 5.1 defining the token response says:

Numerical values are included as JSON numbers.

Because of that, AppAuth consider the expires_in field as an additional parameter instead of setting the access token expiration date.

@WilliamDenniss Can you confirm whether it's a provider bug?

@Lontronix
Copy link

@jojo91 I'm having the same issue. Were you ever able to get around this?

@WilliamDenniss
Copy link
Member

@julienbodet does sounds like this is a provider bug to me.

@WilliamDenniss WilliamDenniss added the provider-bug Issues that are affected by bugs or spec non-compliance by an OAuth2 AS / OIDC IDP label Mar 28, 2020
@WilliamDenniss
Copy link
Member

WilliamDenniss commented Mar 28, 2020

@jojo91 we don't typically change AppAuth to support non-spec compliant providers. However, you can clone the repo and change that rule for your own copy if you wish. You can simply reference AppAuth as a local pod (like the samples do it's pretty easy to setup).

@mysticvalley
Copy link

Hey @jojo91 , I am having same issue as above. Would you kindly share if you were able to get around this issue? Thank you.

@fukemy
Copy link

fukemy commented May 19, 2021

hi, i saw u intergrate appAuth with login using username/password.

***Just login with your login and password natively (not with a webview, with OIDAuthorizationService.perform(tokenRequest))***

Can you tech me how to do it, im facing same problem too

@bmanahilov
Copy link

Hi, I have the same issue when requesting new tokens from https://login.microsoftonline.com/{tenant-id}/oauth2/token. If I am using v2.0 of the API everything's good, but v1 gives all the values as strings. Any advice how to workaround this without forking the framework?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider-bug Issues that are affected by bugs or spec non-compliance by an OAuth2 AS / OIDC IDP
Projects
None yet
Development

No branches or pull requests

7 participants