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

'expiresIn' in iOS has an incorrect value #685

Closed
6 tasks done
jess-hwang opened this issue Aug 2, 2023 · 4 comments
Closed
6 tasks done

'expiresIn' in iOS has an incorrect value #685

jess-hwang opened this issue Aug 2, 2023 · 4 comments
Labels
bug This points to a verified bug in the code iOS Used to denote issues raised for iOS Platform

Comments

@jess-hwang
Copy link

jess-hwang commented Aug 2, 2023

Checklist

Description

"authorize" returns "expiresIn" in Unix timestamp format, but in iOS, when using "saveCredentials," the value is mistakenly assigned using "timeIntervalSinceNow," leading to incorrect values for "expiresIn."
I think it should be "timeIntervalSince1970."
"expiresIn" contains strange dates like "2077-03-03 22:24:35 +0000."

Reproduction

I tested it in version 3.0.0-beta.3.

Additional context

No response

react-native-auth0 version

3.0.0-beta.3

React Native version

0.68.2

Expo version

No response

Platform

iOS

Platform version(s)

16.4

@jess-hwang jess-hwang added the bug This points to a verified bug in the code label Aug 2, 2023
@brushton-ces
Copy link

I'm seeing something similar.

After a normal authorise, I was seeing getCredentials return
"expiresIn": 3381989740,
but the accessToken returned was decoding to "exp": 1691038070,

And then after calling getCredentials with force refresh I got
"expiresIn": 1691195705,
and the accessToken returned was decoding to "exp": 1691195705,
Which seems to properly match.

So it seems the expiresIn value from the initial login was not correct? The authorise method uses the saveCredentials method -

await client.credentialsManager.saveCredentials(credentials);

This error leads to hasValidCredentials returning true when the accessToken returned has expired...

@poovamraj poovamraj added the iOS Used to denote issues raised for iOS Platform label Aug 4, 2023
@poovamraj
Copy link
Contributor

@Widcket Can you check this one out?

@Widcket
Copy link
Contributor

Widcket commented Aug 4, 2023

Hi @jess-hwang, thanks for raising this.

I just reproduced this issue. Indeed, the expiresIn value returned to the JS layer after login is a Unix timestamp, but it's being added to the current time inside saveCredentials():

Screenshot 2023-08-04 at 9 13 43 PM Screenshot 2023-08-04 at 9 15 14 PM

The solution would be to use the Date(timeIntervalSince1970:) initializer instead.

@poovamraj
Copy link
Contributor

Hi @jess-hwang and @brushton-ces thanks for raising this. We have fixed this in the PR here - #686.

Please test it and let us know. We will close this issue and the conversation can be continued there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code iOS Used to denote issues raised for iOS Platform
Projects
None yet
Development

No branches or pull requests

4 participants