Last active
February 25, 2020 09:16
-
-
Save dinesh16/264423f82152e786e829862b189b6917 to your computer and use it in GitHub Desktop.
Aws cognito create user in ruby
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
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 = "[email protected]" | |
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: "[email protected]", | |
}, | |
], | |
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