-
Notifications
You must be signed in to change notification settings - Fork 268
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
TokenManager does not refresh access token successfully #559
Comments
@jelhan - Thanks for the report. You have run afoul of the defaults, which says that a user is not "authenticated" without both an idToken and an accessToken. (see https://github.com/okta/okta-auth-js#authstatemanager ) You can work around this by changing the definition of "isAuthenticated" using the transformAuthState config option: https://github.com/okta/okta-auth-js#transformauthstate You would want to set
|
Thanks for the quick response. I added the |
( I spent several minutes trying to find a way to say "well that's not good" in a professional manner) I'll consult with the rest of the team to figure out how to get this to behave as intended. Are you blocked by this, or is this an inconvenience that can wait until we have a permanent solution? |
Internal ref: OKTA-352791 |
We wanted to use
We need to deliver this functionality within the next weeks. If this bug is not resoled we would be required to implement it ourselves, which is a lot of additional work. We would appreciate if there is any chance for a hot fix or a work-a-round. |
@jelhan The features you want should be supported in Here is a sample to follow: https://github.com/okta/okta-auth-js/tree/master/samples/generated/webpack-spa |
@shuowu Thanks for your reply. But to be honest I can't follow. If I didn't missed something in Your documentation Could you please provide required changes to the minimal reproduction given above? |
@jelhan Basically, the For the renew process, you can call tokenManager.renew to start the renew process. And subscribe to the authState change with authStateManager.subscribe Here are some code links from the linked sample in the last comment: subscribe to authState change: https://github.com/okta/okta-auth-js/blob/master/samples/generated/webpack-spa/src/index.js#L63 |
@shuowu I'm very sorry but I can't follow. I provide a simplified reproduction in this bug report. It can be summarized as the following:
I now even tried to disable automatically renewal I'm using Just to be clear: I was not able yet add all to use the renew logic of Could this be caused by using an incompatible Okta server version? I haven't found a compatibility matrix in the documentation. Or is it maybe related to not using PKCE? Please note that we set |
@jelhan Sorry about the confusion. Can you tried the sample app shared above to see if you can repro the issue? I tried the authentication and renewal flows in it, but failed the reproduce the issue you have. It would also be great if you can share the specific error you have, like the network log. Here is a relevant issue about the endless renew loop which caused by customizing the system clock okta/okta-oidc-js#894 |
The sample app does not use the functionality we need. It's also way more complex than the simplified reproduction I have included in this GitHub issue. My reproduction has 30 lines of code. The sample app has 439 lines of code. Are you able to reproduce my bug report using the reproduction I included in the initial comment? If not: What additional information do you need? I also created a case in Okta help desk so that you can link this bug report to the customer. Happy to share more code or do a screen sharing session if that helps you with debugging.
The system clock is not customized. |
@jelhan Here is a quick write-up in react (I feel it's easier to include both js and jsx together), you can move the logic out from
|
@shuowu That example is not matching what we want to do. Our requirements can be summarized as the following:
As far as I'm aware this is only possible by using low-level APIs like
We came to the point where we needed to evaluate this again. To do so we decided to evaluate if Keeping this bug open as we may want to consider replacing our custom solution with the features provided by |
@jelhan Thank you for the concise and detailed description of the problem. I was able to reproduce the issue using the okta-auth-js test app. There is an assumption in TokenManager that both tokens will be used together. This assumption is obviously flawed. We will fix this issue so that TokenManager correctly supports the case of accessToken with no idToken (OKTA-352791) In the meantime, I believe that TokenManager will satisfy most of your requirements for cross-tab storage. However the
Note that |
@aarongranick-okta Thanks a lot for sharing the update. Glad to hear that you were able to reproduce the bug. I was still worried that we do something wrong. Do you already have an ETA for the bug fix? Thanks a lot for sharing a work-a-round as well. We already rolled out our own solution for cross-tab storage and renewal of the tokens as we needed it urgently. I think we will use that one until the bug is fixed. |
Hi all, I believe we ran into a similar issue @jelhan is experiencing. We ended up having to fork The problem with the existing
Here is the function that works for our use case, which adapts the export async function renewTokensWithRefreshOverrideId(
oktaAuth: OktaAuth,
accessTokenToRefresh: AccessToken,
refreshTokenObject: RefreshToken,
): Promise<TokenResponse> {
const clientId: string = (accessTokenToRefresh.claims as any).cid
const tokenParams = {
clientId,
}
const tokenResponse = await postRefreshToken(oktaAuth, tokenParams, refreshTokenObject)
const urls = getOAuthUrls(oktaAuth, {})
return await handleOAuthResponse(oktaAuth, tokenParams, tokenResponse, urls)
} |
Bump, any updates on this? |
I'm facing some issues with refresh of tokens in
TokenManager
.I fetch an access token and add it to
TokenManager
. On refresh I see token manager trying to fetch an ID token additionally.If
scopes
used to fetch the access token do not contain'openid'
, it fails with an error complaining about missing'openid'
scope.If
scopes
used to fetch the access token do contain'openid'
, I see an endless loop of refreshes.Here is a simplified reproduction:
The text was updated successfully, but these errors were encountered: