-
Notifications
You must be signed in to change notification settings - Fork 550
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
Android get SIGNED_OUT_USER_POOLS_TOKENS_INVALID after 1 hour #815
Comments
By the way, we only use the SDK sign in API. the login UI is written by ourself. |
Hi @jiafei1986 , I see that you are using the synchronous version of the method. Are you making the call from the main/UI thread? Can you try running it in a background thread? Or use the async version of the method.
|
Hi @minbi But we have to pass this idToken to many APIs of our backend. does it mean we need to wrap our business logic code inside the getTokens callback everywhere? |
The |
@minbi Thank you for your quick reply. Yes, we have implemented that listener. what I am trying to ask is what is the correct way to get the tokens? For example, we have 10 APIs need this idToken, so we need to get token first and then pass them to our API. as you mentioned above. we should use AWSMobileClient.getInstance().getTokens(Callback), right? |
Yes.
This should handled by the async variant recommended above. It will create the network request on a background thread. Then, the listener will notify you if you need to sign in again OR if you wish the token request to fail call |
Hi, We are closing this issue because there has been no activity. Please feel free to open a new issue if the problem persists. We ask this because closed issues are not actively monitored. Thanks |
Describe the bug
We are doing the login with the amplify sdk. so far we found an issue that the sdk will return SIGNED_OUT_USER_POOLS_TOKENS_INVALID after 1 hour. and from the document, it suggests user to log in again which is not expected for the user. it will also block the UI thread after that. the user cannot do anything after that.
To Reproduce
A code sample or steps:
Which AWS service(s) are affected?
We use the id token to pass to our backend
Expected behavior
SDK should get the new idToken and it should not hit this error.
Another question is that i just checked aws code, it will send a HTTP call to refresh id and access token if these tokens expired. as we know android not allow to run network call on UI thread. does it mean I need to set a callback everywhere when i use this id token as i don't know what time the token expire?. because our backend API need the id token.
Screenshots
2019-03-26 16:15:51.617 25199-25199/com.expampe W/AWSMobileClient: signalTokensNotAvailable
2019-03-26 16:15:51.620 25199-25199/com.expampe W/AWSMobileClient: Tokens are invalid, please sign-in again.
java.lang.Exception: No cached session.
at com.amazonaws.mobile.client.AWSMobileClient$7$2.signalTokensNotAvailable(AWSMobileClient.java:1538)
at com.amazonaws.mobile.client.AWSMobileClient$7$2.onFailure(AWSMobileClient.java:1533)
at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser.getSession(CognitoUser.java:752)
at com.amazonaws.mobile.client.AWSMobileClient$7.run(AWSMobileClient.java:1500)
at com.amazonaws.mobile.client.internal.InternalCallback.await(InternalCallback.java:115)
at com.amazonaws.mobile.client.AWSMobileClient.getTokens(AWSMobileClient.java:1434)
at com.amazonaws.mobile.client.AWSMobileClient.getUserStateDetails(AWSMobileClient.java:929)
at com.amazonaws.mobile.client.AWSMobileClient.waitForSignIn(AWSMobileClient.java:838)
at com.amazonaws.mobile.client.AWSMobileClient$7.run(AWSMobileClient.java:1450)
at com.amazonaws.mobile.client.internal.InternalCallback.await(InternalCallback.java:115)
2019-03-26 16:15:51.620 25199-25199/com.expampe D/AWSMobileClient: waitForSignIn: userState:SIGNED_OUT_USER_POOLS_TOKENS_INVALID
2019-03-26 16:15:51.621 25199-29008/com.expampe I/userState: need to login again
2019-03-26 16:15:51.639 25199-25199/com.expampe D/AWSMobileClient: Inspecting user state details
2019-03-26 16:15:51.689 25199-25199/com.expampe I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
2019-03-26 16:15:51.689 25199-25199/com.expampe I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
2019-03-26 16:15:51.691 25199-25199/com.expampe W/AWSMobileClient: signalTokensNotAvailable
2019-03-26 16:15:51.693 25199-25199/com.expampe W/AWSMobileClient: Tokens are invalid, please sign-in again.
java.lang.Exception: No cached session.
at com.amazonaws.mobile.client.AWSMobileClient$7$2.signalTokensNotAvailable(AWSMobileClient.java:1538)
at com.amazonaws.mobile.client.AWSMobileClient$7$2.onFailure(AWSMobileClient.java:1533)
at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser.getSession(CognitoUser.java:752)
at com.amazonaws.mobile.client.AWSMobileClient$7.run(AWSMobileClient.java:1500)
at com.amazonaws.mobile.client.internal.InternalCallback.await(InternalCallback.java:115)
at com.amazonaws.mobile.client.AWSMobileClient.getTokens(AWSMobileClient.java:1434)
at com.amazonaws.mobile.client.AWSMobileClient.getUserStateDetails(AWSMobileClient.java:929)
at com.amazonaws.mobile.client.AWSMobileClient.waitForSignIn(AWSMobileClient.java:850)
at com.amazonaws.mobile.client.AWSMobileClient$7.run(AWSMobileClient.java:1450)
at com.amazonaws.mobile.client.internal.InternalCallback.await(InternalCallback.java:115)
Environment Information (please complete the following information):
Additional context
From our backend , they set the refresh token to 30 days.
The text was updated successfully, but these errors were encountered: