Tajib Smajlović
Tajib Smajlović

Reputation: 79

Change AWS Cognito User Pool token expirations from my own backend

I'm aware that the token expirations can be changed in the AWS Cognito Console -> General settings -> App Clients.

Now, is it possible to change the token expiration from my own backend, that is to create an endpoint that will accept value for the expiration and save it to the AWS Cognito just like It would be saved(changed) from the AWS Cognito Console?

Upvotes: 1

Views: 811

Answers (1)

fedonev
fedonev

Reputation: 25749

Yes. The SDKs have an UpdateUserPoolClient API* that accepts token validity times as request attributes.

(Of course, any changes affect only new tokens issued by the user pool client. Existing token expiry is baked into the JWT and cannot be changed)


* Pro Tip: To discover the API behind any console action, observe the Network tab in your browser DevTools when saving a console change. The API name can be found in the Headers: x-amz-target: AWSCognitoIdentityProviderService. UpdateUserPoolClient. The request inputs are in the Payload: UserPoolClient: {...AccessTokenValidity: 90, TokenValidityUnits: {AccessToken: "minutes", IdToken: "minutes", RefreshToken: "days"}, UserPoolId: "us-east-1_wuxxxxxx",...}.

Upvotes: 2

Related Questions