[英]AWS Cognito Credentials Provider for IOS - access key and secret key are nil
I am trying to use AWSCognito
in Objective C to authenticate to an Amazon SimpleDB database. 我正在尝试在目标C中使用AWSCognito
来对Amazon SimpleDB数据库进行身份验证。 I initalize an AWSCognitoCredentialsProvider
with the identity pool id provided in my Amazon account. 我使用我的亚马逊账户中提供的身份池ID来AWSCognitoCredentialsProvider
。 The problem is that when I try to get the access key and secret key from the AWSCognitoCredentialsProvider
object, they are nil. 问题是,当我尝试从AWSCognitoCredentialsProvider
对象获取访问密钥和AWSCognitoCredentialsProvider
密钥时,它们为nil。
I initalize the credentials provider likes this: 我像这样初始化凭证提供者:
AWSCognitoCredentialsProvider *credentialsProvider = [AWSCognitoCredentialsProvider credentialsWithRegionType:AWSRegionUSEast1 accountId:ACCOUNT_ID identityPoolId:IDENTITY_POOL_ID unauthRoleArn:UNAUTH_ROLE authRoleArn:AUTH_ROLE];
AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
After that, I am trying to initialize a SimpleDB client likes this: 之后,我试图像这样初始化一个SimpleDB客户端:
sdbClient = [[AmazonSimpleDBClient alloc] initWithAccessKey:[credentialsProvider accessKey] withSecretKey:[credentialsProvider secretKey]];
Am I doing something wrong? 难道我做错了什么?
Are you mixing version 1 and 2 of the AWS Mobile SDK for iOS? 您是否正在混合适用于iOS的AWS Mobile SDK的版本1和版本2? They are not designed to be used together, and you should consider migrating to the version 2 entirely. 它们并非旨在一起使用,因此您应该考虑完全迁移到版本2。
The v2 SDK automatically calls - refresh
on credentials providers when appropriate. v2 SDK自动调用- refresh
在适当时- refresh
凭据提供者。 Because you are not using AWSSimpleDB
, - refresh
has never been called, and that is why accessKey
and secretKey
return nil
. 因为你不使用AWSSimpleDB
, - refresh
从未被调用,这就是为什么accessKey
和secretKey
回报nil
。
AWSCognitoCredentialsProvider
generates AWS temporary credentials consisting of accessKey
, secretKey
, and sessionKey
. AWSCognitoCredentialsProvider
生成AWS包括临时凭证accessKey
, secretKey
,和sessionKey
。 - initWithAccessKey:withSecretKey:
does not take temporary credentials, and even if you manually call - refresh
on the credentials provider, AmazonSimpleDBClient
does not function. - initWithAccessKey:withSecretKey:
不获取临时凭证,即使您手动调用- refresh
在凭证提供者上- refresh
, AmazonSimpleDBClient
也无法运行。
I recommend rewriting the app using AWSSimpleDB
instead of AmazonSimpleDBClient
in order to use Amazon Cognito Identity. 我建议使用AWSSimpleDB
而不是AmazonSimpleDBClient
重写应用程序,以便使用Amazon Cognito Identity。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.