如何在没有 AmazonSecurityTokenServiceClient 的情况下调用 AssumeRoleWithSAMLAsync
How to call AssumeRoleWithSAMLAsync without AmazonSecurityTokenServiceClient
我正在使用 AmazonSecurityTokenServiceClient 调用 AssumeRoleWithSAMLAsync,在创建客户端对象时必须配置凭据,而我的目的是使用 AssumeRoleWithSaml 创建临时凭据。
AWS STS 服务的文档说 AssumeRoleWithSaml 不需要凭据,但客户端构造函数需要凭据。
我也试过用下面的参数直接调用api
https://sts.amazonaws.com/ ?Version=2011-06-15&Action=AssumeRoleWithSAML&RoleArn=arn:aws:iam::xxx:role/xxx&DurationSeconds=900&PrincipalArn=arn:aws:iam::xxx:saml-provider/adfs&SAMLAssertion=base64 ecoded SAML token
但这也会引发错误
<Code>InvalidIdentityToken</Code>
<Message>Invalid base64 SAMLResponse (Service: AWSOpenIdDiscoveryService; Status Code: 400; Error Code: AuthSamlInvalidSamlResponseException; Request ID: xx-xxxx-xxx)</Message>
配置凭据时,我可以创建临时凭据。因此我确定我的 SAML 令牌是正确的。
谁能告诉我如何从邮递员那里调用 AssumeRoleWithSAML?或者如何在不实例化客户端的情况下通过代码调用它?
在我看来这是先有鸡还是先有蛋的问题。
您可以使用 AnonymousAWSCredentials class 创建客户端可以使用的凭据,同时将 SAML 令牌交换为您的临时角色凭据。
我正在使用 AmazonSecurityTokenServiceClient 调用 AssumeRoleWithSAMLAsync,在创建客户端对象时必须配置凭据,而我的目的是使用 AssumeRoleWithSaml 创建临时凭据。
AWS STS 服务的文档说 AssumeRoleWithSaml 不需要凭据,但客户端构造函数需要凭据。
我也试过用下面的参数直接调用api
https://sts.amazonaws.com/ ?Version=2011-06-15&Action=AssumeRoleWithSAML&RoleArn=arn:aws:iam::xxx:role/xxx&DurationSeconds=900&PrincipalArn=arn:aws:iam::xxx:saml-provider/adfs&SAMLAssertion=base64 ecoded SAML token
但这也会引发错误
<Code>InvalidIdentityToken</Code>
<Message>Invalid base64 SAMLResponse (Service: AWSOpenIdDiscoveryService; Status Code: 400; Error Code: AuthSamlInvalidSamlResponseException; Request ID: xx-xxxx-xxx)</Message>
配置凭据时,我可以创建临时凭据。因此我确定我的 SAML 令牌是正确的。
谁能告诉我如何从邮递员那里调用 AssumeRoleWithSAML?或者如何在不实例化客户端的情况下通过代码调用它?
在我看来这是先有鸡还是先有蛋的问题。
您可以使用 AnonymousAWSCredentials class 创建客户端可以使用的凭据,同时将 SAML 令牌交换为您的临时角色凭据。