Skip to content

decode_authorization_message

decode_authorization_message(
    encoded_message: encodedMessageType,
    *,
    config_overrides: Optional[STSClientConfig] = None,
) -> DecodeAuthorizationMessageResponse

Decodes additional information about the authorization status of a request from an encoded message returned in response to an Amazon Web Services request.

For example, if a user is not authorized to perform an operation that he or she has requested, the request returns a Client.UnauthorizedOperation response (an HTTP 403 response). Some Amazon Web Services operations additionally return an encoded message that can provide details about this authorization failure.

Only certain Amazon Web Services operations return an encoded authorization message. The documentation for an individual operation indicates whether that operation returns an encoded message in addition to returning an HTTP code.

The message is encoded because the details of the authorization status can contain privileged information that the user who requested the operation should not see. To decode an authorization status message, a user must be granted permissions through an IAM policy to request the DecodeAuthorizationMessage (sts:DecodeAuthorizationMessage) action.

The decoded message includes the following type of information:

  • Whether the request was denied due to an explicit deny or due to the absence of an explicit allow. For more information, see Determining Whether a Request is Allowed or Denied in the IAM User Guide.

  • The principal who made the request.

  • The requested action.

  • The requested resource.

  • The values of condition keys in the context of the user's request.

Parameters:

  • encoded_message (encodedMessageType) –

    The encoded message that was returned with the response.

Raises:

  • InvalidAuthorizationMessageException –

    The error returned if the message passed to DecodeAuthorizationMessage was invalid. This can happen if the token contains invalid characters, such as line breaks, or if the message has expired.

  • UnknownServiceError –

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

Examples:

To decode information about an authorization status of a request

>>> client.decode_authorization_message(encoded_message='<encoded-message>')
Source code in docs_src/capo_sts/_services/sts.py
def decode_authorization_message(
    self,
    encoded_message: "capo_sts.types.encoded_message_type.encodedMessageType",
    *,
    config_overrides: Optional[STSClientConfig] = None,
) -> "capo_sts.types.decode_authorization_message_response.DecodeAuthorizationMessageResponse":
    """<p>Decodes additional information about the authorization status of a request from an encoded message returned in response to an Amazon Web Services request.</p> <p>For example, if a user is not authorized to perform an operation that he or she has requested, the request returns a <code>Client.UnauthorizedOperation</code> response (an HTTP 403 response). Some Amazon Web Services operations additionally return an encoded message that can provide details about this authorization failure. </p> <note> <p>Only certain Amazon Web Services operations return an encoded authorization message. The documentation for an individual operation indicates whether that operation returns an encoded message in addition to returning an HTTP code.</p> </note> <p>The message is encoded because the details of the authorization status can contain privileged information that the user who requested the operation should not see. To decode an authorization status message, a user must be granted permissions through an IAM <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html">policy</a> to request the <code>DecodeAuthorizationMessage</code> (<code>sts:DecodeAuthorizationMessage</code>) action. </p> <p>The decoded message includes the following type of information:</p> <ul> <li> <p>Whether the request was denied due to an explicit deny or due to the absence of an explicit allow. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html#policy-eval-denyallow">Determining Whether a Request is Allowed or Denied</a> in the <i>IAM User Guide</i>. </p> </li> <li> <p>The principal who made the request.</p> </li> <li> <p>The requested action.</p> </li> <li> <p>The requested resource.</p> </li> <li> <p>The values of condition keys in the context of the user's request.</p> </li> </ul>

    Args:
        encoded_message: <p>The encoded message that was returned with the response.</p>

    Raises:
        capo_sts.errors.invalid_authorization_message_exception.InvalidAuthorizationMessageException: <p>The error returned if the message passed to <code>DecodeAuthorizationMessage</code> was invalid. This can happen if the token contains invalid characters, such as line breaks, or if the message has expired.</p>
        capo_sts.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To decode information about an authorization status of a request

        >>> client.decode_authorization_message(encoded_message='<encoded-message>')
    """

    def _handler(
        req: "OperationRequest[capo_sts.types.decode_authorization_message_request.DecodeAuthorizationMessageRequest]",
    ) -> OperationResponse[
        "capo_sts.types.decode_authorization_message_response.DecodeAuthorizationMessageResponse"
    ]:
        import capo_sts._operations.aws_security_token_service_v20110615.decode_authorization_message

        output, http_response = (
            capo_sts._operations.aws_security_token_service_v20110615.decode_authorization_message.decode_authorization_message(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DecodeAuthorizationMessage")
    )
    input_: capo_sts.types.decode_authorization_message_request.DecodeAuthorizationMessageRequest = {
        "encoded_message": encoded_message
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output