上传到Amazon S3和Rails的服务器调用亚马逊Cognito身份 [英] Upload to Amazon S3 and Calling Amazon Cognito Identity from Rails server

查看:264
本文介绍了上传到Amazon S3和Rails的服务器调用亚马逊Cognito身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图按照从iOS应用程序上传文件到Amazon S3的步骤。

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

据AWS的iOS的SDK文档,上传前,需要进行身份验证的应用程序,用户通过我的后端服务器的安全访问AWS资源: 的http://docs.aws.amazon.com/mobile/sdkforios/developerguide/cognito-auth.html#providing-creds

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

什么是正确的方式来调用AWS Cognito身份 GetOpenIdTokenForDeveloperIdentity 从轨服务(4.1版)服务器?

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

这个服务是不是AWS-SDK宝石的一部分。

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

推荐答案

Cognito仅通过在 V2的Ruby支持SDK

Cognito is only supported via the the v2 Ruby SDK.

下面是一个使用V2 SDK一个小例子为 GetOpenIdTokenForDeveloperIdentity

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 - 池的ID
  • 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
    • 响应(成功时)将包含 identity_id 标记为您的用户,可以通过回为您的移动应用程序。

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

      这篇关于上传到Amazon S3和Rails的服务器调用亚马逊Cognito身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆