Guest User

Untitled

a guest
Nov 5th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. client = Aws::CognitoIdentityProvider::Client.new(
  2. access_key_id: "xxxx",
  3. secret_access_key: "xxxx",
  4. region: "us-east-1"
  5. )
  6.  
  7. # Base64 ( HMAC_SHA256 ( "Client Secret Key", "Username" + "Client Id" ) )
  8. username = "dinesh16@gmail.com"
  9. key = App_client_secret # (get this from amazon cognito console)
  10. data = username + App_client_id # (get App_client_id from amazon console)
  11.  
  12. secret_hash = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, data)).strip
  13.  
  14. resp = client.sign_up({
  15. client_id: "xxx", # required
  16. secret_hash: secret_hash,
  17. username: username, # required
  18. password: "AbCdEpoioQ!", # required
  19. user_attributes: [
  20. {
  21. name: "email", # required
  22. value: "dinesh16@gmail.com",
  23. },
  24. ],
  25. analytics_metadata: {
  26. analytics_endpoint_id: "StringType",
  27. },
  28. user_context_data: {
  29. encoded_data: "StringType",
  30. },
  31. })
Add Comment
Please, Sign In to add comment