Skip to content

Instantly share code, notes, and snippets.

@dinesh16
Last active February 25, 2020 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dinesh16/264423f82152e786e829862b189b6917 to your computer and use it in GitHub Desktop.
Save dinesh16/264423f82152e786e829862b189b6917 to your computer and use it in GitHub Desktop.
Aws cognito create user in ruby
client = Aws::CognitoIdentityProvider::Client.new(
access_key_id: "xxxx",
secret_access_key: "xxxx",
region: "us-east-1"
)
# Base64 ( HMAC_SHA256 ( "Client Secret Key", "Username" + "Client Id" ) )
username = "dinesh16@gmail.com"
key = App_client_secret # (get this from amazon cognito console)
data = username + App_client_id # (get App_client_id from amazon console)
secret_hash = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, data)).strip
resp = client.sign_up({
client_id: "xxx", # required
secret_hash: secret_hash,
username: username, # required
password: "AbCdEpoioQ!", # required
user_attributes: [
{
name: "email", # required
value: "dinesh16@gmail.com",
},
],
analytics_metadata: {
analytics_endpoint_id: "StringType",
},
user_context_data: {
encoded_data: "StringType",
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment