How to efficiently retrieve tokens from Cognito while using amplify with react-native ?

0

I am creating an app using Amplify with react-native. For backend, I am using Cognito token for current user using Auth.currentSession(). The issue with this approach is that every time i need to call backend server, I need to call Auth.currentSession(). Is there any other approach I can use apart from increasing token validity ?

1 Answer
0

Hello, thank you for your question. As I understand, you wish to retrieve access tokens from Cognito without needing to continuously call Auth.currentSession(). After the initial Auth.currentSession() call, JWT tokens can be retrieved from your local cache by utilizing the Cache module. Please refer to the link below for examples and additional information.

https://docs.amplify.aws/lib/auth/advanced/q/platform/js/#retrieve-jwt-tokens

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions