Contact Us 1-800-596-4880

Connected Application Authentication

Connected application authentication enables access to Exchange using OAuth 2.0 client credentials, so you can execute Exchange requests without sending user credentials.

Create a Connected Application

To create a new connected application:

  1. Log in to Anypoint Platform.

  2. Go to Access Management > Connected Apps > Create App.

  3. Select App acts on its own behalf (client credentials).

  4. Click Add Scopes and add the appropriate Exchange scopes:

    • Exchange Administrator or Exchange Contributor for read and write access

    • Exchange Viewer for read-only access

  5. Select the business groups and environments for the scopes, and click Add Scopes.

  6. Click Save and copy the client ID and client secret of the connected application.

For more information about creating connected apps, see Creating Connected Apps in Anypoint Platform.

Obtain a Bearer Token

Use the OAuth 2.0 client_credentials grant type to obtain a bearer token for the connected application. Replace CLIENT_ID and CLIENT_SECRET with your client ID and secret:

curl --location --request POST 'https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=CLIENT_ID' \
--data-urlencode 'client_secret=CLIENT_SECRET' \
--data-urlencode 'grant_type=client_credentials'

You receive a response similar to:

{
    "access_token": "YOUR_BEARER_TOKEN",
    "token_type": "bearer"
}

Use this bearer token in Exchange API calls by including it in the Authorization header:

curl -H 'Authorization: bearer YOUR_BEARER_TOKEN' \
https://anypoint.mulesoft.com/exchange/api/v2/assets

Basic Authentication for Maven Facade and Graph API

The Exchange Maven Facade API and the Exchange Graph API also support a basic authentication shortcut using connected application credentials directly. To use this method, define the username as ~~~Client~~~ and the password as clientID~?~clientSecret.

Replace clientID with the client ID and clientSecret with the client secret.

For example, in a Maven settings.xml file:

<servers>
  <server>
    <id>Repository</id>
    <username>~~~Client~~~</username>
    <password>clientID~?~clientSecret</password>
  </server>
</servers>

For the Exchange Experience API, MuleSoft recommends using the bearer token method.