Contact Free trial Login

To Obtain an API Bearer Token Using a SAML Assertion

This topic describes how to obtain the bearer token from Anypoint Platform. If you are using an identity provider configured to use SAML 2.0, federated users within your organization can access platform APIs using the bearer token.

The bearer token provides access to the platform APIs a user has permission to access. Each bearer token is associated with a specific user who is granted roles and permissions for an API. If a user attempts to access an API that they do not have permissions to access the API returns a 401 Unauthorized error.

The validity of the bearer token is determined by the value defined for the Default Session Timeout property. This is configured in the Master organization properties. See Organization Settings for more information.

To obtain an API bearer token using a SAML assertion:

  1. Obtain a SAML response for your identity provider as described in To View a SAML Response in Your Browser.

    Record this response to use in the following step.

  2. Obtain the bearer token by running the following curl command. Replace <SAML_RESPONSE> in this example with the SAML response you obtained in the previous step.

    curl -X POST \ \
      -H 'Content-Type: application/json' \
      -H 'X-Requested-With: XMLHttpRequest' \
      -d '{
        "SAMLResponse": "<SAML_RESPONSE>"

After obtaining the bearer token federated users within your organization can use it to access an API. For example, you can access the API using one of the following methods:

  • Anypoint CLI: A user can access a platform API by supplying the -bearer option to the anypoint-cli command. See Anypoint CLI for more information.

  • curl: A user can access a platform API by passing the bearer token when accessing an API endpoint as shown in the following:

    curl -X GET \ \
      -H 'Authorization: Bearer <BEARER_TOKEN>'

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.