To Test the Local Provider

To test the OAuth 2.0 provider, you encode the client ID and client secret in base64 according to the HTTP Basic Authentication specification RFC 2617. This specification has been superseded by RFC 7235, but describes HTTP Basic Authentication better than RFC 7235. You run the provider as a Mule application locally. The provider checks the client ID and client secret that you entered in Anypoint Platform preferences against the base64-encoded credentials, and returns an access token if there is a match.

To test the provider:

  1. In Studio, select the project folder oauth2-cust-provider and select Run As > Mule application with Maven.

  2. Create a base64-encoded string containing the client ID and client secret pair, separated by a colon (note that the command-line below is for Mac OS X or Linux; Windows users may need to download tools to do this).

    echo '<Client Id>:<Client Secret>' | base64

    The encoded pair appears. For example:


  3. Request a token using the user name/password credentials specified in the project: user max, password mule. Substitute your own base64-encoded credentials for NmJl…​RDYK1

    curl -i -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic NmJl...RDYK" -d 'grant_type=password&username=max&password=mule' 'https://localhost:8082/external/access_token' -k

    The output includes the access token. For example:

    HTTP/1.1 200
    Content-Length: 250
    Content-Type: application/json; charset=UTF-8
    Date: Thu, 13 Oct 2016 22:05:41 GMT
  4. In a browser, enter the following URL, specifying the access token to validate a call to the provider:


    The output looks something like this:

    {"expires_in":1460,"scope":"", "client_id":"6be...c2a","username":"max"}

    In the Studio console, the AUTH SUCCESSFUL message appears.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub
Submit your feedback!
Share your thoughts to help us build the best documentation experience for you!
Take our latest survey!