boto3 - 获取请求标头?

问题描述 投票:0回答:1

有人知道如何从 boto3 获取请求对象标头吗?

例如:

client = boto3.client('cognito-identity', region_name=aws_session.region_name)

response = client.get_id(
    IdentityPoolId=amplify_outputs['auth']['identity_pool_id'],
)

响应结果:

{'IdentityId': 'us-west-2:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx',
 'ResponseMetadata': {'RequestId': '48a7f4f9-52aa-49b2-b150-e0722dd15319',
  'HTTPStatusCode': 200,
  'HTTPHeaders': {'date': 'Wed, 22 May 2024 12:40:12 GMT',
   'content-type': 'application/x-amz-json-1.1',
   'content-length': '63',
   'connection': 'keep-alive',
   'x-amzn-requestid': '48a7f4f9-52aa-49b2-b150-e0722dd15319',
   'strict-transport-security': 'max-age=31536000; includeSubDomains'},
  'RetryAttempts': 0}}

我问的原因是我正在尝试使用 HTTP 测试一些端点。

我在 Cloud Watch 或 Cognito 控制台中找不到身份提供商的任何痕迹,并且我还无法从 boto3 客户端获取请求。

amazon-web-services boto3 amazon-cognito
1个回答
0
投票

boto3 与 AWS 的交互与 AWSCLI 与 AWS 的交互相同。 Boto3 只是将您的代码转换为 API 调用。

因此,您可以使用 bash 终端在 AWSCLI 中执行相同的 API 查询,并使用流量嗅探器来捕获包。

我会遵循本教程 --> https://docs.telerik.com/fiddler-everywhere/knowledge-base/capturing-aws-traffic

这里有示例代码的 AWSCLI 命令 --> https://docs.aws.amazon.com/cli/latest/reference/cognito-identity/get-id.html

© www.soinside.com 2019 - 2024. All rights reserved.