Skip to content

Instantly share code, notes, and snippets.

@alarv
alarv / cognito-generate-token-with-secret.sh
Created January 10, 2023 11:37
Generate a token for cognito using cognito-idp, SMS_MFA method (OTP with an SMS) and secret_hash
#!/bin/bash
username=
password=
clientid=
client_secret=
region=
user_pool_id=
aws_profile=
secret_hash=$(echo -n "${username}${clientid}" | openssl dgst -sha256 -hmac ${client_secret} -binary | openssl enc -base64)