1

我正在尝试AWSCognito在 Objective C 中使用对 Amazon SimpleDB 数据库进行身份验证。我AWSCognitoCredentialsProvider使用我的 Amazon 帐户中提供的身份池 ID 初始化一个。问题是当我尝试从对象中获取访问密钥和密钥时AWSCognitoCredentialsProvider,它们是零。

我像这样初始化凭据提供程序:

 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;

之后,我试图初始化一个 SimpleDB 客户端,如下所示:

sdbClient = [[AmazonSimpleDBClient alloc] initWithAccessKey:[credentialsProvider accessKey] withSecretKey:[credentialsProvider secretKey]]; 

难道我做错了什么?

4

1 回答 1

1

您是否混合使用适用于 iOS 的 AWS 移动开发工具包的版本 1 和 2?它们不是为一起使用而设计的,您应该考虑完全迁移到版本 2。

The v2 SDK automatically calls - refresh on credentials providers when appropriate. Because you are not using AWSSimpleDB, - refresh has never been called, and that is why accessKey and secretKey return nil.

AWSCognitoCredentialsProvider generates AWS temporary credentials consisting of accessKey, secretKey, and sessionKey. - initWithAccessKey:withSecretKey: does not take temporary credentials, and even if you manually call - refresh on the credentials provider, AmazonSimpleDBClient does not function.

I recommend rewriting the app using AWSSimpleDB instead of AmazonSimpleDBClient in order to use Amazon Cognito Identity.

于 2015-03-12T20:17:46.623 回答