【问题标题】:Amazon Web Services : Error - The security token included in the request is invalidAmazon Web Services:错误 - 请求中包含的安全令牌无效
【发布时间】:2015-02-20 20:59:18
【问题描述】:

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

我已按照文档中的教程进行操作: Using 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;
}];

有谁知道我做错了什么?

【问题讨论】:

  • 您应该通过调用 [AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose; 来启用详细日志记录。这可能是调试问题的第一步。

标签: ios iphone amazon-web-services amazon-cognito


【解决方案1】:

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

还有一件事可能会让您感到困惑,那就是您没有包含 unauth 角色。确保您的身份提供者没有遇到this question 中提到的问题,这会阻止它担任您的身份验证角色。

【讨论】:

  • 我检查了刷新并创建了一个未经身份验证的角色以供使用。我现在收到“未授权执行 sts:AssumeRoleWithWebIdentity”错误。我已经检查了角色信任和权限,一切看起来都井井有条……有什么想法吗?
猜你喜欢
  • 1970-01-01
  • 2019-04-20
  • 1970-01-01
  • 2016-12-12
  • 2018-04-09
  • 2020-02-01
  • 2014-01-30
  • 2021-06-22
  • 1970-01-01
相关资源
最近更新 更多