-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Manually set refresh token #5198
Comments
Hi @tschoffelen This is currently not supported, but one thing you can try is to look into localStorage for the key where it is stored: amplify-js/packages/amazon-cognito-identity-js/src/CognitoUser.js Lines 1323 to 1328 in 16b6695
|
Okay, that's a shame. Is this not a use case that you expect to come across more often? |
Our team is having similar issues. We would like to be able to ingest a refresh token between apps for an SSO solution. Here is a reference to our Amazon support ticket: Case ID 7031693371 Summary of problem: We have multiple apps under ellen umbrella on which we want to implement SSO flow using Cognito User Pool (federation enabled for Facebook, Google etc), but we would not want to use the Cognito hosted UI since we have a few custom flows to complete the authentication for the user before she enters their credentials and after the authentication is completed. We want to spin up our own standalone app (preferably using amplify) which would handle the authentication using CUP and finally redirect the Cognito tokens to the calling app. We were wondering if there is an option to be able to control the callback url without using the Cognito hosted UI. Applications that require authentication: Application that handles authentication: Flow: Code on application C: Auth.signIn(username, password); We are having trouble at Step 2. We are currently unable to leverage OAuth callbacks from our authentication app without navigating to Cognito hosted UI. We had a call with Amazon support and were instructed to pass the refresh token between our applications, but it is not sufficient to log a user in without the id Token and the access token. |
@cardinalm7 how did you solve this? I've got the same requirement |
Hey @mbsimonovic There are other solutions that could have worked... Amplify uses 4 local storage keys to create its session, refresh token, id token, device key, and I can't remember the other key... easy to discover by removing the keys and seeing if Amplify can authenticate. If you can transfer these values from one app to the other (perhaps with a query param or a custom API), then you can transfer the session. I recommend using the most secure version of the solution if you are passing tokens around. Some helpful tips that I wish someone explained to me at the beginning of my oauth journey: Auth.currentSession will refresh the user's id and access token ONCE their tokens expire. I hope this was helpful! |
@tschoffelen @mbsimonovic @cardinalm7 I will mark this issues as a feature request, Thanks for all the feedback |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Which Category is your question related to?
Auth
What AWS Services are you utilizing?
Cognito
Provide additional details e.g. code snippets
We're building a custom authentication flow where the user will get a refresh token (generated from a Cognito user pool) externally from Amplify. What is the
easiest way of passing that refresh token into Amplify?
I was hoping to find something like
Auth.setRefreshToken()
, so that we could then use functions likeAuth.currentUser()
out of the box, but I can't find something like that in the docs.Am I missing something?
The text was updated successfully, but these errors were encountered: