AWS SSO GetRoleCredentials API 详解


ref: https://docs.aws.amazon.com/singlesignon/latest/PortalAPIReference/API_GetRoleCredentials.html

返回分配给用户的给定角色名称的 STS 短期凭证。

请求语法


GET /federation/credentials?account_id=accountId&role_name=roleName HTTP/1.1
x-amz-sso_bearer_token: accessToken

响应语法


HTTP/1.1 200
Content-type: application/json
{
"roleCredentials": {
"accessKeyId": "string",
"expiration": number,
"secretAccessKey": "string",
"sessionToken": "string"
}
}

实例


URL 地址:https://portal.sso.{region}.amazonaws.com

这里的 region 替换成实际的 region 即可。

注意:以下例子中,为了便于展示,对所有的 JSON 进行了格式化。

1. 请求


GET /federation/credentials?account_id=42xxxxx44&role_name=xxx HTTP/1.1
Host: portal.sso.us-east-1.amazonaws.com
Accept-Encoding: gzip, deflate
Connection: close
x-amz-sso_bearer_token: ******

2. 响应


HTTP/1.1 200 OK
Date: Wed, 10 Sep 2025 07:14:05 GMT
Content-Type: application/json
Content-Length: 1080
Connection: close
Access-Control-Expose-Headers: RequestId
Access-Control-Expose-Headers: x-amzn-RequestId
Cache-Control: no-cache
RequestId: 2683b57e-cc3d-412d-b6a9-484f57cbd497
Server: AWS SSO
x-amzn-RequestId: 2683b57e-cc3d-412d-b6a9-484f57cbd497
{
"roleCredentials": {
"accessKeyId":"ASIAWFSxxxxxxxxJW",
"secretAccessKey":******,
"sessionToken":******,
"expiration":1757492044000
}
}
Published at:
September 19, 2025
Keywords:
AWS
Amazon S3
SSO
OIDC