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 Antwort
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

beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen