Next-generation platform

Authenticating Store Inventory Management REST APIs

Learn how to authenticate by using OAuth2 client credentials before calling the Store Inventory Management REST APIs.

Before you begin

Ensure that you have completed the onboarding process and received the hostname, tenantId, client_id, and client_secret through an email.

About this task

You can call the Store Inventory Management REST APIs by using OAuth2 client credentials.

Procedure

  1. Generate a token by calling the auth API, https://<hostname>/<tenantid>/oauth2/token, with HTTP method as POST.
    Additionally, ensure that the following elements contain the appropriate parameters:
    • The headers include:
      • "Content-Type: application/json"
    • The body includes (in json format):
      • “client_id” : “”
      • “client_secret” : “”
      • “grant_type” : “client_credentials”

    The API output contains the token and time (in seconds) before it expires.

  2. Call the required REST API with this token by passing it in the header as follows:
    Authorization: Bearer <token>

Example

Consider you have received the following information from the onboarding team:
  • tenantId=tenant-abc
  • client_id=xyz
  • client_secret=123

To call the Create a location REST API, complete the following:

  1. Generate a token by calling the auth API, https://<hostname>/tenant-abc/oauth2/token, with HTTP method as POST with the following parameters:
    • Headers
      • Content-Type : application/json
    • Request Body
      { "client_id" : "xyz",
      "client_secret" : "123",
      "grant_type" : "client_credentials"
      }
    • Response contains the token
      { "token_type" : "bearer",
      "access_token" :"<token>",
      "expires_in":"7200"
      }
  2. Call the Create a location REST API – (prefix host and tenantId to the URI).
    • POST https://<hostname>/tenant-abc/v1/stores/storeId/locations
    • Headers
      • Content-Type : application/json
      • Authorization: Bearer <token>
    • Request body - API body