GetRoleCredentialsCommand

Returns the STS short-term credentials for a given role name that is assigned to the user.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { SSOClient, GetRoleCredentialsCommand } from "@aws-sdk/client-sso"; // ES Modules import
// const { SSOClient, GetRoleCredentialsCommand } = require("@aws-sdk/client-sso"); // CommonJS import
const client = new SSOClient(config);
const input = { // GetRoleCredentialsRequest
  roleName: "STRING_VALUE", // required
  accountId: "STRING_VALUE", // required
  accessToken: "STRING_VALUE", // required
};
const command = new GetRoleCredentialsCommand(input);
const response = await client.send(command);
// { // GetRoleCredentialsResponse
//   roleCredentials: { // RoleCredentials
//     accessKeyId: "STRING_VALUE",
//     secretAccessKey: "STRING_VALUE",
//     sessionToken: "STRING_VALUE",
//     expiration: Number("long"),
//   },
// };

GetRoleCredentialsCommand Input

See GetRoleCredentialsCommandInput for more details

Parameter
Type
Description
accessToken
Required
string | undefined

The token issued by the CreateToken API call. For more information, see CreateToken  in the IAM Identity Center OIDC API Reference Guide.

accountId
Required
string | undefined

The identifier for the AWS account that is assigned to the user.

roleName
Required
string | undefined

The friendly name of the role that is assigned to the user.

GetRoleCredentialsCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
roleCredentials
RoleCredentials | undefined

The credentials for the role that is assigned to the user.

Throws

Name
Fault
Details
InvalidRequestException
client

Indicates that a problem occurred with the input to the request. For example, a required parameter might be missing or out of range.

ResourceNotFoundException
client

The specified resource doesn't exist.

TooManyRequestsException
client

Indicates that the request is being made too frequently and is more than what the server can handle.

UnauthorizedException
client

Indicates that the request is not authorized. This can happen due to an invalid access token in the request.

SSOServiceException
Base exception class for all service exceptions from SSO service.