Skip to content

get_delegated_access_token async

get_delegated_access_token(
    trade_in_token: tradeInTokenType,
    *,
    config_overrides: Optional[AsyncSTSClientConfig] = None,
) -> GetDelegatedAccessTokenResponse

Exchanges a trade-in token for temporary Amazon Web Services credentials with the permissions associated with the assumed principal. This operation allows you to obtain credentials for a specific principal based on a trade-in token, enabling delegation of access to Amazon Web Services resources.

Parameters:

  • trade_in_token (tradeInTokenType) –

    The token to exchange for temporary Amazon Web Services credentials. This token must be valid and unexpired at the time of the request.

Raises:

  • ExpiredTradeInTokenException –

    The trade-in token provided in the request has expired and can no longer be exchanged for credentials. Request a new token and retry the operation.

  • PackedPolicyTooLargeException –

    The request was rejected because the total packed size of the session policies and session tags combined was too large. An Amazon Web Services conversion compresses the session policy document, session policy ARNs, and session tags into a packed binary format that has a separate limit. The error message indicates by percentage how close the policies and tags are to the upper size limit. For more information, see Passing Session Tags in STS in the IAM User Guide.

    You could receive this error even though you meet other defined session policy and session tag limits. For more information, see IAM and STS Entity Character Limits in the IAM User Guide.

  • RegionDisabledException –

    STS is not activated in the requested region for the account that is being asked to generate credentials. The account administrator must use the IAM console to activate STS in that region. For more information, see Activating and Deactivating STS in an Amazon Web Services Region in the IAM User Guide.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sts/_services/async_sts.py
async def get_delegated_access_token(
    self,
    trade_in_token: "capo_sts.types.trade_in_token_type.tradeInTokenType",
    *,
    config_overrides: Optional[AsyncSTSClientConfig] = None,
) -> "capo_sts.types.get_delegated_access_token_response.GetDelegatedAccessTokenResponse":
    """<p>Exchanges a trade-in token for temporary Amazon Web Services credentials with the permissions associated with the assumed principal. This operation allows you to obtain credentials for a specific principal based on a trade-in token, enabling delegation of access to Amazon Web Services resources.</p>

    Args:
        trade_in_token: <p>The token to exchange for temporary Amazon Web Services credentials. This token must be valid and unexpired at the time of the request.</p>

    Raises:
        capo_sts.errors.expired_trade_in_token_exception.ExpiredTradeInTokenException: <p>The trade-in token provided in the request has expired and can no longer be exchanged for credentials. Request a new token and retry the operation.</p>
        capo_sts.errors.packed_policy_too_large_exception.PackedPolicyTooLargeException: <p>The request was rejected because the total packed size of the session policies and session tags combined was too large. An Amazon Web Services conversion compresses the session policy document, session policy ARNs, and session tags into a packed binary format that has a separate limit. The error message indicates by percentage how close the policies and tags are to the upper size limit. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html">Passing Session Tags in STS</a> in the <i>IAM User Guide</i>.</p> <p>You could receive this error even though you meet other defined session policy and session tag limits. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-limits-entity-length">IAM and STS Entity Character Limits</a> in the <i>IAM User Guide</i>.</p>
        capo_sts.errors.region_disabled_exception.RegionDisabledException: <p>STS is not activated in the requested region for the account that is being asked to generate credentials. The account administrator must use the IAM console to activate STS in that region. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html#sts-regions-activate-deactivate">Activating and Deactivating STS in an Amazon Web Services Region</a> in the <i>IAM User Guide</i>.</p>
        capo_sts.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_sts.types.get_delegated_access_token_request.GetDelegatedAccessTokenRequest]",
    ) -> AsyncOperationResponse[
        "capo_sts.types.get_delegated_access_token_response.GetDelegatedAccessTokenResponse"
    ]:
        import capo_sts._operations.aws_security_token_service_v20110615.get_delegated_access_token

        (
            output,
            http_response,
        ) = await capo_sts._operations.aws_security_token_service_v20110615.get_delegated_access_token.async_get_delegated_access_token(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_sts.types.get_delegated_access_token_request.GetDelegatedAccessTokenRequest",
    ) -> dict[str, Any]:
        import capo_sts.types.get_delegated_access_token_request

        return capo_sts.types.get_delegated_access_token_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_sts.types.get_delegated_access_token_response.GetDelegatedAccessTokenResponse",
    ) -> dict[str, Any]:
        import capo_sts.types.get_delegated_access_token_response

        return capo_sts.types.get_delegated_access_token_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "GetDelegatedAccessToken",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_sts.types.get_delegated_access_token_request.GetDelegatedAccessTokenRequest = {
        "trade_in_token": trade_in_token
    }

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