0

我在我的 iOS 应用程序中为我们的 Amazon Cognito 设置了开发人员身份验证身份

我已按照文档中的教程进行操作: 使用 Developer Authenticated Identities

我的后端能够毫无问题地生成令牌并获取 identityIds。而且我可以按照指示在我的 iOS 应用程序中初始化 cognito。但是我在发出 dynamoDb 请求时收到错误消息

The security token included in the request is invalid

Cognito 初始化代码:

 MyIdentityProvider *identityProvider = [MyIdentityProvider new];
[identityProvider setIdentityPoolId:COGNITO_POOL_ID];

AWSCognitoCredentialsProvider *credentialsProvider  = [[AWSCognitoCredentialsProvider alloc]
                                                       initWithRegionType:AWSRegionUSEast1
                                                       identityProvider:identityProvider
                                                       unauthRoleArn:nil
                                                       authRoleArn:COGNITO_ROLE_AUTH];




AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1
                                                                      credentialsProvider:credentialsProvider];

[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;





[[credentialsProvider getIdentityId] continueWithSuccessBlock:^id(BFTask *task){

 //In here I can see that everything is ok.
 //I have a token and cognitoId
 //But despite this, when I make requests I get "The security token included in the request is  invalid"

 return nil;
}];

有谁知道我可能做错了什么?

4

1 回答 1

0

getIdentityId仅确保您获得了一个 identityId,您可能需要验证您是否可以成功调用refresh凭证提供程序,因为这将确保您能够成功获得凭证。显式调用refresh在生产中不是必需的,但在测试中可能很有价值。

也可能让你绊倒的一件事是你没有包括一个未经授权的角色。确保您的身份提供者没有遇到此问题中提到的问题,这将阻止它获得您的身份验证角色。

于 2014-12-22T20:38:48.973 回答