getAuthorizationToken method

Future<GetAuthorizationTokenResponse> getAuthorizationToken({
  1. List<String>? registryIds,
})

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 AWS 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.

May throw ServerException. May throw InvalidParameterException.

Parameter registryIds : A list of AWS account IDs that are associated with the registries for which to get AuthorizationData objects. If you do not specify a registry, the default registry is assumed.

Implementation

Future<GetAuthorizationTokenResponse> getAuthorizationToken({
  List<String>? registryIds,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target':
        'AmazonEC2ContainerRegistry_V20150921.GetAuthorizationToken'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (registryIds != null) 'registryIds': registryIds,
    },
  );

  return GetAuthorizationTokenResponse.fromJson(jsonResponse.body);
}