Upload to Amazon S3 and Calling Amazon Cognito Ide

2019-02-25 10:42发布

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

According to the AWS iOS SDK docs, before uploading, it is required to authenticate the app users for secure access to AWS resources via my backend server: http://docs.aws.amazon.com/mobile/sdkforios/developerguide/cognito-auth.html#providing-creds

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

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

1条回答
地球回转人心会变
2楼-- · 2019-02-25 11:23

Cognito is only supported via the the v2 Ruby SDK.

Here 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 - The ID of your pool
  • MY_PROVIDER_NAME - The provider name you configured on your identity pool
  • USER_IDENTIFIER - The unique identifier for this user in your system

The response (when successful) will contain an identity_id and token for your user, which can be passed back to your mobile application.

查看更多
登录 后发表回答