-
Notifications
You must be signed in to change notification settings - Fork 549
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
You must be signed-in with Cognito Userpools to be able to use getTokens #3558
Comments
Here the word
|
"but there is no more such functionality in the latest versions." @Andrew0000 Can you clarify what version of Amplify you are using? The above statement gives me the impression you may have updated to Amplify v2. Amplify v2 and AWS Android SDK are not compatible with each other. See this guide on compatibility. https://docs.amplify.aws/android/sdk/configuration/amplify-compatibility/ |
To answer your other question about awsconfiguration.json, the Amplify CLI still creates this file, alongside amplifyconfiguration.json. |
The code I provided worked on 1.x.x
It's absolutely inconvenient (and causes questions) to use CLI for such a basic thing like the android library setup. |
@Andrew0000 I'm not currently sure what your usage, but it is likely that you can entirely remove the AWS Android SDK and use Amplify only. Amplify can get tokens by calling:
See here for more info: https://docs.amplify.aws/android/build-a-backend/auth/accessing-credentials/ |
Thank you, this looks like a possible solution. |
@tylerjroach By the way, |
I'm not sure if there is a use case where you would want expired tokens, but this is the reason that fetchAuthSession is async.
If you want to use these values synchronously, you can always grab the tokens and then cache them to be used synchronously instead. You can also look into using our Kotlin Coroutines support which would help you write async code in a cleaner way. https://docs.amplify.aws/android/start/project-setup/kotlin-coroutines/ |
State your question
I try to get tokens via
AWSMobileClient.getInstance().tokens
and the SDK throws the errorYou must be signed-in with Cognito Userpools to be able to use getTokens
.The user has a userpool and it's not clear what to do.
Which AWS Services are you utilizing?
AWS Cognito + com.amazonaws:aws-android-sdk-mobile-client:2.73.0
Provide code snippets (if applicable)
val tokens = AWSMobileClient.getInstance().tokens
Stacktrace:
Environment(please complete the following information):
Device Information (please complete the following information):
Additional details:
Previously I was able to get tokens via:
but there is no more such functionality in the latest versions.
The text was updated successfully, but these errors were encountered: