Authenticate a Connected App with CMS

Generate OAuth credentials, and send an HTTP request to the Salesforce REST API with those credentials to authenticate a connected app with CMS. If the request is successful, the response contains an access token to use in your code for future API requests.

Generate CMS authentication credentials for the app.

  1. From Setup, in the Quick Find box, enter Apps, and select App Manager.
  2. Click New Connected App and enter the details for your app.
  3. Enable OAuth for the connected app, and enter a callback URL. CMS directs the connected app to that address after authentication completes, so this URL must have corresponding code in your app.
  4. Click Save and then click Continue. In the API section, save the Consumer Key and Consumer Secret because you need them in your app code.

To send an API call to retrieve an access token for CMS, make an HTTP POST request to the endpoint.

In the request body, include these parameters.

  • client_id—The client ID from when you generated OAuth credentials for your connected app.

  • client_secret—The client secret from when you generated OAuth credentials for your connected app.

  • grant_type—The type of authentication to perform. In this case, set it to password.

  • username—A user with access to the content you want to share.

  • password—The password of a user with access to the content that you want to share.

This Node.js sample requests an access token for CMS.

The response to the authentication request contains a JSON object that includes the access_token field. Use the access token to authenticate in future API requests.

This sample is the response body from an authentication request.