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

一个人想着一个人 提交于 2019-12-04 04:42:49

问题


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:


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.



来源:https://stackoverflow.com/questions/26704404/upload-to-amazon-s3-and-calling-amazon-cognito-identity-from-rails-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!