Jump to Content

Class GetAuthorizationTokenCommandProtected

Retrieves an authorization token. An authorization token represents your IAM authentication credentials and can be used to access any Amazon ECR registry that your IAM principal has access to. The authorization token is valid for 12 hours.

The authorizationToken returned is a base64 encoded string that can be decoded and used in a docker login command to authenticate to a registry. The CLI offers an get-login-password command that simplifies the login process. For more information, see Registry authentication in the Amazon Elastic Container Registry User Guide.

Example

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

import { ECRClient, GetAuthorizationTokenCommand } from "@aws-sdk/client-ecr"; // ES Modules import
// const { ECRClient, GetAuthorizationTokenCommand } = require("@aws-sdk/client-ecr"); // CommonJS import
const client = new ECRClient(config);
const input = { // GetAuthorizationTokenRequest
registryIds: [ // GetAuthorizationTokenRegistryIdList
"STRING_VALUE",
],
};
const command = new GetAuthorizationTokenCommand(input);
const response = await client.send(command);

Param

GetAuthorizationTokenCommandInput

Returns

GetAuthorizationTokenCommandOutput

See

Throws

InvalidParameterException (client fault)

The specified parameter is invalid. Review the available parameters for the API request.

Throws

ServerException (server fault)

These errors are usually caused by a server-side issue.

Example

To obtain an authorization token

// This example gets an authorization token for your default registry.
const input = {};
const command = new GetAuthorizationTokenCommand(input);
const response = await client.send(command);
/* response ==
{
"authorizationData": [
{
"authorizationToken": "QVdTOkN...",
"expiresAt": "1470951892432",
"proxyEndpoint": "https://012345678901.dkr.ecr.us-west-2.amazonaws.com"
}
]
}
*/
// example id: getauthorizationtoken-example-1470867047084

Hierarchy

Constructors

Properties

Methods