Python 创建boto3 sts客户端时出现无效标头值错误

Python 创建boto3 sts客户端时出现无效标头值错误,python,amazon-web-services,boto3,botocore,Python,Amazon Web Services,Boto3,Botocore,我使用一个内部IDP进行身份验证,然后使用SAML断言来承担角色,使用boto3 sts客户端。与IDP的交互很好,在成功验证后能够生成SAML断言,但当我尝试生成sts客户端“client=boto3.client('sts')”时,botocore抛出了无效的头值错误 错误来自我们的出口代理服务器 File "/usr/local/lib/python3.8/dist-packages/aws_authentication/credentials.py", line 21

我使用一个内部IDP进行身份验证,然后使用SAML断言来承担角色,使用boto3 sts客户端。与IDP的交互很好,在成功验证后能够生成SAML断言,但当我尝试生成sts客户端“client=boto3.client('sts')”时,botocore抛出了无效的头值错误

错误来自我们的出口代理服务器

File "/usr/local/lib/python3.8/dist-packages/aws_authentication/credentials.py", line 219, in decode_saml_assertion
    client = boto3.client('sts')
  File "/usr/local/lib/python3.8/dist-packages/boto3/__init__.py", line 93, in client
    return _get_default_session().client(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/boto3/session.py", line 258, in client
    return self._session.create_client(
  File "/usr/local/lib/python3.8/dist-packages/botocore/session.py", line 826, in create_client
    credentials = self.get_credentials()
  File "/usr/local/lib/python3.8/dist-packages/botocore/session.py", line 430, in get_credentials
    self._credentials = self._components.get_component(
  File "/usr/local/lib/python3.8/dist-packages/botocore/credentials.py", line 1975, in load_credentials
    creds = provider.load()
  File "/usr/local/lib/python3.8/dist-packages/botocore/credentials.py", line 1028, in load
    metadata = fetcher.retrieve_iam_role_credentials()
  File "/usr/local/lib/python3.8/dist-packages/botocore/utils.py", line 486, in retrieve_iam_role_credentials
    role_name = self._get_iam_role(token)
  File "/usr/local/lib/python3.8/dist-packages/botocore/utils.py", line 518, in _get_iam_role
    return self._get_request(
  File "/usr/local/lib/python3.8/dist-packages/botocore/utils.py", line 427, in _get_request
    response = self._session.send(request.prepare())
  File "/usr/local/lib/python3.8/dist-packages/botocore/httpsession.py", line 356, in send
    raise HTTPClientError(error=e)

botocore.exceptions.HTTPClientError: An HTTP Client raised an unhandled exception: Invalid header value b'---- proxy error response ----'

出现此问题的原因是,在botocore包中,\u fetch\u metadata\u token函数正在连接到用于获取元数据令牌的url

要成功连接到169.254.169.254,我已将其添加到no_proxy,以便出口代理服务器不会阻止连接

no_proxy=localhost,169.254.169.254
在将元数据端点169.254.169.254添加到no_代理之后,我能够连接到sts并生成客户端