Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cognito Token Expiring After 1 Hour

I'm using the AWS Cognito JavaScript SDK to authorize and authenticate users in my React Native app.

I've managed to provide and store an IdentityId for users. Users who do not log in have access to part of my app as long as we authorize them with a confirmation because of Federated Identities / IAM. This all works well.

My question is, after an hour the token is expiring and their access is being limited because of it. What should be the process here? Do I retrieve new tokens, or do some sort of token refresh? What does that look like?

There is so much AWS Cognito documentation out there but I haven't really been able to find exactly what I need; and on top of, that I'm finding it really confusing to tell what I need for a successful Federated Identities / IAM authorization flow vs. what I need for a successful User Pool / log in flow.

like image 402
chapeljuice Avatar asked Aug 11 '17 14:08

chapeljuice


People also ask

How long do AWS Cognito tokens last?

By default, Amazon Cognito refresh tokens expire 30 days after a user signs in to a user pool. When you create an app, you can set the app's refresh token expiration to any value between 60 minutes and 10 years.

What happens when Cognito token expires?

If the refresh token is expired, your app user must re-authenticate by signing in again to your user pool. If the minimum for the access token and ID token is set to 5 minutes, and you are using the SDK, the refresh token will be continually used to retrieve new access and ID tokens.

How long should refresh tokens live?

Refresh tokens have a longer lifetime than access tokens. The default lifetime for the refresh tokens is 24 hours for single page apps and 90 days for all other scenarios. Refresh tokens replace themselves with a fresh token upon every use.


1 Answers

you have the credentials... and you called credentials.get() that first time... now on a timer after 55mins call credentials.refresh()... so you will have the credentials updated before they expire (do it every time you get a new credential... in 55mins refresh)

like image 54
UXDart Avatar answered Oct 04 '22 06:10

UXDart