- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
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
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
accessToken Required | string | undefined | The token issued by the |
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 |
---|
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 |
---|
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. |