Setting Up OAuth with Point of Sale APIs

Point of Sale supports OAuth for secure authentication with APIs and SPIs. Configure the OAUTH-OAuth SPI by entering the required URL, client secret, and headers. This setup allows the system to obtain an authentication token before making any other SPI calls.

CMS Configuration and Setup 

To configure OAuth authentication for Point of Sale APIs, set up the OAUTH-OAuth SPI connector in CMS and then configure your individual SPIs to use the generated authentication tokens. The process involves two main steps: first establishing the OAuth connection, then applying it to your specific API integrations.

Configuring OAUTH-OAuth SPI 

  1. In CMS, go to Integrations > Custom Connectors.
  2. Click Create.
  3. For Connector Type, select SPI.
  4. For Endpoint Name, select OAUTH-OAuth.
  5. Update the API Endpoint to add grant_type=client_credentials. For example, https://interdev.my.sf.com/services/oauth2/token?grant_type=client_credentials.
  6. Set the Integration Type to HTTP_POST.
  7. Specify the authorization key using the JSON Headers.
    1. Retrieve the Client ID and Client Secret from the external API.
    2. Generate a Base64 concatenated Client ID and Client Secret, with a colon (:) and a single space.
    3. Add this string to the JSON Headers.
1{
2  "Content-Type": "application/x-www-form-urlencoded",
3  "Authorization": "Basic M01WRzlGSU5PMW5zeFJ1QVRUODVIOEVzMVZ5eUhWemNFd1BmQ0dkZnNSQlhVQUJlSjJ2YXFDSE00cG9vd2k2c2tZQnZiN2xqLkl0ZnQ0ZTVacXNQbTogQjg1MjFBNEFFMjZBMzJERDQwOTZDMzlCODJCN0UyQjhEQjRBNUIxMjU3MUEwQUYwQjlBREM3Qjg5OTEyQTBEQQ=="
4}
  • Include a space after the word Basic (don’t include a colon).
  • Generate the basic token by concatenating the Client ID and Client Secret with a colon and space. For example, client_id: client_secret.

Note

mceclip0.png

Example SPI Response 

1{
2  "token_type": "Bearer",
3  "expires_in": 3600, //Optional field - Number of seconds this key will be present in cache for subsequent SPI calls
4  "access_token": "*****" // Token sent as part of the header in other SPI requests.
5}

Configuring SPIs with OAuth 

  1. In CMS, go to Integrations > Custom Connectors.
  2. Click Create in the upper right.
  3. For Connector Type, select SPI.
  4. For Endpoint Name, select an SPI. For example, SHIPPING_METHOD.
  5. Navigate to the OAuth Config settings.
  6. Set the OAuth Header to the header of your choice.
  7. Set the OAuth API Key to either OAuth or OAUTH.
  8. Configure the rest of the required fields.
  9. Save your changes.

mceclip3.png

Example SPI Request with Headers 

1{
2  "httpHeaders": {
3    "Authorization": "Bearer *****",
4    "Content-Type": "application/json"
5  }
6}