Open mohammad-shafi-mck opened 1 year ago
@mohammad-shafi-mck okta-auth-js uses Date.now()
to calculate the expiresAt
field in the token, which means the time you see from the token will be in UTC(timezone agnostic). I think the issue most probably locate in the api token validation part.
You can also follow the expires_in
field from the decoded token, the token should still be active if the number is positive.
Describe the bug?
In Cypress, OktaAuth() is returning a JWT token with an 'issued time' time of 1 hour ago and expiry time of now.
In a cypress suite using okta-auth-js to log in via the API, The JWT token expires as soon as it is created, so any following api requests via Okta return a 4XX and the user is logged out, causing tests to fail.
*This may be unrelated but, this bug began when the British time zone changed from time change from GMT(UTC) to BST(UTC+1)
What is expected to happen?
A JWT token with an 'issued time' of now and an 'expiry time' of now + 1 hour.
What is the actual behavior?
In Cypress, OktaAuth() is returning a JWT token with an 'issued time' time of 1 hour ago and expiry time of now.
Reproduction Steps?
use the programmatic way of logging in to an okta app in a cypress test https://docs.cypress.io/guides/end-to-end-testing/okta-authentication#Programmatic-Login
create a new instance of
OktaAuth()
, and retrieve the JWT token generated within itSave the token to your local storage under the key 'oktaCypress'
the decode the JWT in a JWT decoding tool and observe the token was issued 1 hour ago and has expired now.
SDK Versions
"okta": "^1.0.0" "@okta/okta-auth-js": "^6.8.0"
Execution Environment
node v18.6.0 Chrome Version 112.0.5615.49
Additional Information?
No response