Created
February 13, 2023 08:13
-
-
Save heiwa4126/c0227f64f77556fcee8a26805cbee1be to your computer and use it in GitHub Desktop.
AWS Cognitoでクライアントシークレットを設定したときの、SECRET_HASHの作り方
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AWS Cognitoでクライアントシークレットを設定したときの、 | |
// SECRET_HASHの作り方 | |
import { createHmac } from 'crypto'; | |
function generateSecretHash(clientId, secretKey, userName) { | |
const hasher = createHmac('sha256', secretKey); | |
hasher.update(userName + clientId); | |
return hasher.digest('base64'); | |
} | |
// 参考 | |
// - https://aws.amazon.com/jp/premiumsupport/knowledge-center/cognito-unable-to-verify-secret-hash/ | |
// - https://dev.to/shamsup/creating-the-secret-hash-for-aws-cognito-in-nodejs-50f7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment