【问题标题】:An error occurred (ResourceNotFoundException) when calling the GetCredentialsForIdentity operation: Identity 'ap-south-1:sadf'调用 GetCredentialsForIdentity 操作时发生错误 (ResourceNotFoundException):Identity 'ap-south-1:sadf'
【发布时间】:2020-07-08 15:22:02
【问题描述】:

当我使用 IdentityId 和 Logins 调用 GetCredentialsForIdentity 时出现 ResourceNotFoundException

client_identify = boto3.client('cognito-identity', region_name=POOL_REGION)
logins = {}
logins[
    "cognito-idp." + POOL_REGION + ".amazonaws.com/" + USER_POOL
] = id_token;
print(logins, IDENTITY_POOL_ID)
res = client_identify.get_credentials_for_identity(
  IdentityId=IDENTITY_POOL_ID,
  Logins=logins
)

我在这里遇到的错误是: botocore.errorfactory.ResourceNotFoundException:发生错误 (ResourceNotFoundException) 调用 GetCredentialsForIdentity 操作时:Identity 在此处输入代码'ap-south-1:asdfadsfasdfsdafdsadfasdfasd'

当我尝试使用 javascript 时,它工作得非常好。

python有什么解决办法吗?

【问题讨论】:

  • 你确定你指定的IDENTITY_POOL是正确的吗?
  • 是的。我正在使用 IDENTITY_POOL_ID
  • 但是代码中没有IDENTITY_POOL_ID。取而代之的是IDENTITY_POOLPOOL_ID?这些都不一样?
  • 我有更新问题请查收。
  • 我正在关注这个boto3.amazonaws.com/v1/documentation/api/latest/reference/…来实现。他们在这里提到了“IdentityId”,但我提供的是“IDENTITY_POOL_ID”。

标签: python amazon-web-services boto3


【解决方案1】:

IDENTITY_POOL_IDIDENTITY_ID 是两个不同的东西。基本上需要使用get_idIDENTITY_POOL_ID获取IDENTITY_ID

这是我测试的代码:

import boto3  
                                                                                          
                                                
client_identify = boto3.client('cognito-identity')   
                                                  
IDENTITY_POOL_ID = 'us-east-1:xxxxx-3f18-41f9-b4a6-xxxxx' 


response = client_identify.get_id(
         IdentityPoolId=IDENTITY_POOL_ID
)  

print(response)


IDENTITY_ID = response['IdentityId']                                                                      

print(IDENTITY_ID)                             

res = client_identify.get_credentials_for_identity(
       IdentityId=IDENTITY_ID
)

print(res)   

您需要根据自己的要求对其进行调整。

【讨论】:

  • 谢谢,我做的几乎一样,但没有“AccountId”。我所做的一切都是为了将​​我的系统与第三方集成。
  • 这是我从第三方获取的用于集成的数据 { "user":"AAAAAAAAA", "password":"BBBBBBB", "userPool":"CCCCCCCCC", "appClient": "DDDDDDDD", "identityPool":"EEEEEEEEEE", "region":"FFFFFF", "basePath":"testapi.test.co.in/test" }
  • AccountId (string) get_id 中是可选的。因此,你们很多人都不需要它。
  • 谢谢,你帮我分配了。我认为 AccountId 是强制性的
  • @Kanna 没问题。很高兴我能帮忙:-)
猜你喜欢
  • 1970-01-01
  • 2021-04-20
  • 2021-10-02
  • 2016-08-07
  • 2020-01-16
  • 2020-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多