Skip to content

Instantly share code, notes, and snippets.

@heiwa4126
Created February 13, 2023 08:13
Show Gist options
  • Save heiwa4126/c0227f64f77556fcee8a26805cbee1be to your computer and use it in GitHub Desktop.
Save heiwa4126/c0227f64f77556fcee8a26805cbee1be to your computer and use it in GitHub Desktop.
AWS Cognitoでクライアントシークレットを設定したときの、SECRET_HASHの作り方
// 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