Upload to Amazon S3 and Calling Amazon Cognito Identity from Rails Server

I am trying to follow the steps to upload files to Amazon S3 from an iOS app.

According to the AWS iOS SDK docs, application user authentication is required prior to download to securely access AWS resources through my backend server: http://docs.aws.amazon.com/mobile/sdkforios/developerguide/cognito-auth.html#providing- creds

What is the correct way to call AWS Cognito Identity GetOpenIdTokenForDeveloperIdentity service from a rails server (version 4.1)?

This service is not part of the aws-sdk gem.

+3


source to share


1 answer


Cognito is only supported through the v2 Ruby SDK .

Below is a minimal example for GetOpenIdTokenForDeveloperIdentity

using the v2 SDK:

require 'aws-sdk'
cognito = Aws::CognitoIdentity::Client.new(region:'us-east-1')
resp = cognito.get_open_id_token_for_developer_identity(
           identity_pool_id: 'IDENTITY_POOL_ID', 
           logins: {'MY_PROVIDER_NAME' => 'USER_IDENTIFIER'})

      



  • IDENTITY_POOL_ID - your pool ID
  • MY_PROVIDER_NAME . Provider name configured in your identity pool.
  • USER_IDENTIFIER . The unique identifier for this user on your system.

The answer (if successful) will contain identity_id

and token

to your user, which can be transferred back into your mobile application.

+9


source







All Articles