Skip to content

get_authorization_token async

get_authorization_token(
    *,
    config_overrides: Optional[AsyncECRClientConfig] = None,
    registry_ids: Optional[GetAuthorizationTokenRegistryIdList] = None,
) -> GetAuthorizationTokenResponse

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.

Parameters:

  • registry_ids (Optional[GetAuthorizationTokenRegistryIdList], default: None ) –

    A list of Amazon Web Services 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.

Raises:

Source code in docs_src/capo_ecr/_services/async_ecr.py
async def get_authorization_token(
    self,
    *,
    config_overrides: Optional[AsyncECRClientConfig] = None,
    registry_ids: Optional[
        "capo_ecr.types.get_authorization_token_registry_id_list.GetAuthorizationTokenRegistryIdList"
    ] = None,
) -> (
    "capo_ecr.types.get_authorization_token_response.GetAuthorizationTokenResponse"
):
    """<p>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.</p> <p>The <code>authorizationToken</code> returned is a base64 encoded string that can be decoded and used in a <code>docker login</code> command to authenticate to a registry. The CLI offers an <code>get-login-password</code> command that simplifies the login process. For more information, see <a href="https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html#registry_auth">Registry authentication</a> in the <i>Amazon Elastic Container Registry User Guide</i>.</p>

    Args:
        registry_ids: <p>A list of Amazon Web Services 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.</p>

    Raises:
        capo_ecr.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter is invalid. Review the available parameters for the API request.</p>
        capo_ecr.errors.server_exception.ServerException: <p>These errors are usually caused by a server-side issue.</p>
        capo_ecr.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ecr.types.get_authorization_token_request.GetAuthorizationTokenRequest]",
    ) -> AsyncOperationResponse[
        "capo_ecr.types.get_authorization_token_response.GetAuthorizationTokenResponse"
    ]:
        import capo_ecr._operations.amazon_ec2_container_registry_v20150921.get_authorization_token

        (
            output,
            http_response,
        ) = await capo_ecr._operations.amazon_ec2_container_registry_v20150921.get_authorization_token.async_get_authorization_token(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetAuthorizationToken")
    )
    input_: capo_ecr.types.get_authorization_token_request.GetAuthorizationTokenRequest = {}
    if registry_ids is not None:
        input_["registry_ids"] = registry_ids

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output