Generate an authorization bearer token for usage in Anypoint Platform REST APIs
This KB works if your account username is excluded from MFA, If the MFA is mandatory, then it won’t work.
If your organization has implemented external identity management (SSO/SAML), follow the steps - To Obtain an API Bearer Token Using a SAML Assertion.
If you're rather using a non-federated user, follow the steps described in this article.
You can also get a bearer token using the client_id and client_secret of your CloudHub Organization or Environment via OAuth2, as described in the Anypoint Access Management API documentation.
However, this token is mainly helpful for API Manager purposes and is not associated with a user, therefore you cannot use it to call most APIs (for example CloudHub).
If MFA is enabled on the user, the following method to get a token using a username/password can not be used. Please reference Creating connected app and getting the bearer token example, or How to Get the Anypoint Access Token from Chrome Browser Session.
Please see the following CURL comments.
On Mac, replace <USERNAME> and <PASSWORD>:
curl -H "Content-Type: application/json" -X POST -d '{"username":"<USERNAME>","password":"<PASSWORD>"}' "https://anypoint.mulesoft.com/accounts/login"
On Linux, replace my-user and my-pass with your actual username and password for CloudHub, and then run it:
curl -d 'username=my-user&password=my-pass' https://anypoint.mulesoft.com/accounts/login
On Windows please use:
curl -sq 'https://anypoint.mulesoft.com/accounts/login' -H "Content-Type: application/json" -d "{\"username\": \"my-user\",\"password\": \"my-pass\"}"
A JSON output should be generated, you should see an access_token in that output. The such token will be valid for at least 60 minutes, depending on the account configuration.
You can optionally get the organization id to use in other CloudHub API calls. In the following command replace my-token with the bearer token from the previous command, and run:
curl -sq 'https://anypoint.mulesoft.com/accounts/api/me' -H 'Authorization: Bearer my-token'
Please note that this method of accessing the Anypoint API will be going away with the intro of the MFA requirement for all MuleSoft Anypoint Platform users.
001115323

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.