繁体   English   中英

适用于IOS的AWS Cognito凭证提供程序-访问密钥和秘密密钥为零

[英]AWS Cognito Credentials Provider for IOS - access key and secret key are nil

我正在尝试在目标C中使用AWSCognito来对Amazon SimpleDB数据库进行身份验证。 我使用我的亚马逊账户中提供的身份池ID来AWSCognitoCredentialsProvider 问题是,当我尝试从AWSCognitoCredentialsProvider对象获取访问密钥和AWSCognitoCredentialsProvider密钥时,它们为nil。

我像这样初始化凭证提供者:

 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]]; 

难道我做错了什么?

您是否正在混合适用于iOS的AWS Mobile SDK的版本1和版本2? 它们并非旨在一起使用,因此您应该考虑完全迁移到版本2。

v2 SDK自动调用- refresh在适当时- refresh凭据提供者。 因为你不使用AWSSimpleDB- refresh从未被调用,这就是为什么accessKeysecretKey回报nil

AWSCognitoCredentialsProvider生成AWS包括临时凭证accessKeysecretKey ,和sessionKey - initWithAccessKey:withSecretKey:不获取临时凭证,即使您手动调用- refresh在凭证提供者上- refreshAmazonSimpleDBClient也无法运行。

我建议使用AWSSimpleDB而不是AmazonSimpleDBClient重写应用程序,以便使用Amazon Cognito Identity。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM