aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.4k stars 2.11k forks source link

Refresh token integration with React native repack super app #13553

Open akshay-capgemini opened 2 weeks ago

akshay-capgemini commented 2 weeks ago

Is this related to a new or existing framework?

No response

Is this related to a new or existing API?

No response

Is this related to another service?

No response

Describe the feature you'd like to request

I am integrating the refresh token in our current React Native application, which is built using Callstack's Re.Pack. In my application, I can generate a new access token and get sessions in one flow. I need to get the session and generate a new access token even if the app is closed and reopened, and also after the app is killed and reopened.

Are there any methods or ways to get the session when the app is closed and reopened? (I don't want to use local storage or AsyncStorage to store the data from Cognito.)

Describe the solution you'd like

I need to get session details from aws even if I close the app and reopens.

Describe alternatives you've considered

Im trying to reduce the use of async storage and do all the features with the support of amazon-cognito-identity-js. Currently I don't have any solution to achieve my needs.

Additional context

No response

Is this something that you'd be interested in working on?

cwomack commented 2 weeks ago

Hey, @akshay-capgemini šŸ‘‹. Want to ask a couple clarifying questions to better understand the feature request here. Are you trying to have the session destroyed/created again every time the app is opened/closed? And have you tried using the forceRefresh flag in this situation to see if this provides the behavior that you're looking for (see here)?

Also, are you on v5 or v6 of Amplify? I know you're trying to use the amplify-cognito-identity-js package, but just to be clear that is no longer used in v6. We recommend using Amplify JavaScript library's Auth features in place of the Amazon Cognito Identity SDK.

cwomack commented 1 week ago

@akshay-capgemini, just wanted to ping you again to see if you had a chance to review the above comment and provide some additional insight. Thanks!

akshay-capgemini commented 1 week ago

@cwomack My aim is to avoid to store the tokens and data to the local storage to improve the app security. My app works fine when it is live and Im able to get the session, but when I quit or kill the app and try to reopen the app Im not able to get the session from cognito. So I need to know is there any way to get the session even after I quit the app and reopen. Currently all the items is handled by using amplify-cognito-identity-js package.