[Update] Amazon Cognito App Client Secrets Can Now Be Managed with AWS Secrets Manager, So I Tried It Out
This page has been translated by machine translation. View original
Introduction
On November 19, 2026, Amazon Cognito app client secrets can now be managed with AWS Secrets Manager.
When you enable this, Cognito stores the client secret in Secrets Manager and rotates it at regular intervals. On the application side, you read the latest value from Secrets Manager and use it.
In this article, I will enable management for both a new app client and an existing app client, and verify which secrets can be used before and after rotation.
Differences from client secret rotation
Cognito also added support for client secret rotation and custom secrets in February 2026.
This is a mechanism where you add a new secret with AddUserPoolClientSecret and delete the old secret with DeleteUserPoolClientSecret. Since one app client can have up to 2 secrets, you can wait for the application to switch over before deleting the old one.
With this new feature, Cognito performs this addition and deletion automatically[1].
| Item | Feature added in February | Management with Secrets Manager |
|---|---|---|
| Rotation | You call the API yourself | Cognito does it every 7 days by default |
| Retrieving the secret value | The response when the secret is created | GetSecretValue in Secrets Manager |
| Custom secrets | Can be used | Cannot be used |
Enabling management on a new app client
When I created an app client in the management console, "Store secrets in AWS Secrets Manager - Recommended" was the default.

On the other hand, with the API and AWS CLI, it was disabled by default. In the CLI, you specify --publish-secrets-in-aws-secrets-manager together with --generate-secret.
aws cognito-idp create-user-pool-client \
--user-pool-id ap-northeast-1_NtwV7jZ7h \
--client-name managed-new \
--generate-secret \
--publish-secrets-in-aws-secrets-manager \
--allowed-o-auth-flows client_credentials \
--allowed-o-auth-scopes blog-api/read \
--allowed-o-auth-flows-user-pool-client
The response included ClientSecretArn. It seems the plaintext of the secret is not included.
{
"UserPoolClient": {
"UserPoolId": "ap-northeast-1_NtwV7jZ7h",
"ClientName": "managed-new",
"ClientId": "4a6qri5mspfaeqc11sf8cjg38n",
"ClientSecretArn": "arn:aws:secretsmanager:ap-northeast-1:123456789012:secret:cognito-idp!4a6qri5mspfaeqc11sf8cjg38n-oXyHGe",
"AllowedOAuthFlows": [
"client_credentials"
],
"AllowedOAuthScopes": [
"blog-api/read"
],
"AllowedOAuthFlowsUserPoolClient": true
}
}
I couldn't see the secret with describe-user-pool-client or on the console's app client details screen either. When I checked the "Client secrets" tab, it clearly stated that secrets cannot be created, displayed, or deleted from the Cognito API or console.

On the Secrets Manager side, a secret named cognito-idp!<client ID> had been created.
aws secretsmanager describe-secret \
--secret-id 'cognito-idp!4a6qri5mspfaeqc11sf8cjg38n'
{
"Name": "cognito-idp!4a6qri5mspfaeqc11sf8cjg38n",
"RotationEnabled": true,
"RotationRules": {
"AutomaticallyAfterDays": 7
},
"NextRotationDate": "2026-11-28T08:59:59+09:00",
"VersionIdsToStages": {
"3565a8de-9849-4e2b-a0ba-4921b94feea5": [
"AWSCURRENT"
],
"879111fc-51ab-4459-9652-bc54dd56cce8": [
"AWSPENDING"
]
},
"OwningService": "cognito-idp"
}
What caught my attention was VersionIdsToStages: there was an AWSPENDING version right after creation. It seems that even for a newly created app client, the first rotation starts at the same time as creation.
Getting a token with the secret retrieved from Secrets Manager
The SecretString obtained with get-secret-value was JSON like the following.
{
"clientSecretValue": "<クライアントシークレット>",
"userPoolId": "ap-northeast-1_NtwV7jZ7h",
"userPoolClientId": "4a6qri5mspfaeqc11sf8cjg38n"
}
I extract clientSecretValue and send a client_credentials request to the token endpoint.
SECRET=$(aws secretsmanager get-secret-value \
--secret-id 'cognito-idp!4a6qri5mspfaeqc11sf8cjg38n' \
--query SecretString --output text | jq -r .clientSecretValue)
curl -s -u "4a6qri5mspfaeqc11sf8cjg38n:$SECRET" \
-d "grant_type=client_credentials&scope=blog-api/read" \
https://<ドメインのプレフィックス>.auth.ap-northeast-1.amazoncognito.com/oauth2/token
{"access_token":"eyJraWQiOi...","expires_in":3600,"token_type":"Bearer"}
And so, I was able to get a token without any problems using the secret retrieved from Secrets Manager!
Since the first rotation was still in progress, I also tried the value of the AWSPENDING version, and I could get a token with that as well.
The first rotation completed within a few minutes of creation. The value that was AWSPENDING became AWSCURRENT, and the first value became AWSPREVIOUS. I could continue to get tokens with either value.
Trying to enable it on an existing app client
Next, I'll enable management on an existing app client that has a plaintext secret.
I specify --publish-secrets-in-aws-secrets-manager with update-user-pool-client. With UpdateUserPoolClient, settings you don't specify revert to their default values[2], so I also specify the OAuth settings.
aws cognito-idp update-user-pool-client \
--user-pool-id ap-northeast-1_NtwV7jZ7h \
--client-id mso4rdlid0as421uodoue4dp9 \
--client-name existing \
--publish-secrets-in-aws-secrets-manager \
--allowed-o-auth-flows client_credentials \
--allowed-o-auth-scopes blog-api/read \
--allowed-o-auth-flows-user-pool-client
The response returned ClientSecretArn, and a secret was created in Secrets Manager. The AWSCURRENT value was the same as the plaintext secret I had been using before enabling it. This means that simply enabling it does not affect applications that use the existing secret.
This time too, the first rotation started immediately and completed within a few minutes.
Rotating manually
Even after the first rotation finished, the plaintext secret from before enabling remained usable as AWSPREVIOUS. To find out when this old value becomes unusable, I'll look at the next rotation.
I rotated using rotate-secret in Secrets Manager.
aws secretsmanager rotate-secret \
--secret-id 'cognito-idp!mso4rdlid0as421uodoue4dp9'
I tested whether I could get tokens with each value before and after execution, and the results were as follows.
| Value | Before execution | About 30 seconds after execution | After completion |
|---|---|---|---|
| Plaintext secret from before enabling | AWSPREVIOUS, usable |
AWSPREVIOUS, not usable |
Version deleted |
| Value created by the first rotation | AWSCURRENT, usable |
AWSCURRENT, usable |
AWSPREVIOUS, usable |
| Value created by this rotation | None | AWSPENDING, usable |
AWSCURRENT, usable |
The rotation completed within a few minutes of execution, and the plaintext secret from before enabling became unusable immediately after execution, without waiting for the rotation to complete.
Possibly related to this, the documentation recommends reading from Secrets Manager when the app starts, and re-reading and retrying if authentication fails.
Operations that become unavailable once management is enabled
For an app client with management enabled, you can no longer manipulate secrets with AddUserPoolClientSecret. When I tried it, the following error was returned.
aws cognito-idp add-user-pool-client-secret \
--user-pool-id ap-northeast-1_NtwV7jZ7h \
--client-id 4a6qri5mspfaeqc11sf8cjg38n
aws: [ERROR]: An error occurred (InvalidParameterException) when calling the AddUserPoolClientSecret operation: Cannot add a new secret to a client when the client's secrets are managed by AWS Secrets Manager.
delete-user-pool-client-secret was likewise rejected.
aws: [ERROR]: An error occurred (InvalidParameterException) when calling the DeleteUserPoolClientSecret operation: Cannot delete a secret managed by AWS Secrets Manager
You also can't combine it with a custom secret. If you specify both --client-secret and --publish-secrets-in-aws-secrets-manager, it is rejected at creation.
aws: [ERROR]: An error occurred (InvalidParameterException) when calling the CreateUserPoolClient operation: Cannot specify both custom secret and publishSecretsInAWSSecretsManager. Use only one option.
Note that the documentation says these operations fail with InvalidInputException, but what was actually returned at the time of verification was InvalidParameterException. If you branch your handling by error type, be careful.
Disabling management again
Finally, I'll try disabling management on the existing app client.
aws cognito-idp update-user-pool-client \
--user-pool-id ap-northeast-1_NtwV7jZ7h \
--client-id mso4rdlid0as421uodoue4dp9 \
--client-name existing \
--no-publish-secrets-in-aws-secrets-manager \
--allowed-o-auth-flows client_credentials \
--allowed-o-auth-scopes blog-api/read \
--allowed-o-auth-flows-user-pool-client
The response returned the plaintext ClientSecret. The value was the same as the AWSCURRENT just before.
This is because when you remove management, Cognito moves the secret back to the Cognito side and returns the plaintext, just like a conventional app client.
On the other hand, the Secrets Manager secret was deleted immediately, and get-secret-value returned ResourceNotFoundException. It couldn't be restored with restore-secret either.
aws: [ERROR]: An error occurred (ResourceNotFoundException) when calling the RestoreSecret operation: Secrets Manager can't find the specified secret.
Since applications reading from Secrets Manager can no longer get new values once management is disabled, it seems you need to switch the application back to using the plaintext secret beforehand.
Conclusion
By enabling management with Secrets Manager, you can now leave client secret rotation to Cognito. Note that the first rotation starts immediately, both at creation and for existing clients, when you enable it.
Also, since the old value becomes unusable as soon as the next rotation starts, it's safest to build the application so that it re-reads the secret periodically and re-reads it when authentication fails.