Obtain the Authorization Token for your Tenant

Before You Begin

You need the following:
  • The token request URL.
  • Get the following information from the Setup section:
    • Token Request URL
    • Client ID
    • Username
  • The ingestion password that you set up during first-time tenant access as an administrator.
  • Access to a REST client such as Postman or Advanced REST client, or curl CLI.

About This Task

Use this procedure to obtain an authorization bearer token before registering services using Event Hub with your tenant. Also, before ingesting data (assets, alerts, or time series) into a specific tenant. Tokens are client-specific and usually expire within a set time period. You must obtain a new token every time your token expires.

Procedure

  1. Access your REST client.
  2. Enter the token request URL in the HOST value field.
    Note: This URL is used to authenticate the token before connecting to the respective ingestion service. You can obtain this from the Setup section.
  3. Select the POST method.
  4. In the request authorization: enter or select the following:
    1. Select Basic Auth.
    2. In the Username field, enter the Client ID obtained from the Setup section.
    3. Leave the password blank.
    The authorization headers auto populate in the request.
  5. In the request body, select x-www-form-urlencoded.
  6. Enter the following query parameters (key-value pairs):
    Note: You can obtain the values from the Setup section.
    Query ParametersDescription
    grant_typeGrant type for ingestion. The default value is password.
    usernameIngestion account username (for example, 07F28C049E0F4F29B8E85E4A6C916D7F_ingestor).
    passwordIngestion account password created during the initial tenant setup.
  7. Select Send.

Results

On successful ingestion, you receive the authorization bearer token as a JSON response; copy this information into a temporary file. Also, make note of the expires_in field in the JSON response, as it gives the expiration time in seconds.

Example

The following code sample shows a JSON response :

{
  "access_token": "eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI1ZTJjOTBlYS05ZWRkLTRkYTEtODBjOC00YTBkNjdmNzdlZjMiLCJzdWIiOiI2YWY0YjBlNi1mZmY4LTRmOWEtYTdhNC1mYzI5Nzg4ZTY5YzAiLCJzY29wZSI6WyJvcGVuaWQiXSwiY2xpZW50X2lkIjoiaW5nZXN0b3IuREU2QjcxODQyODI0NENGMkE0MDlGM0YwRUU1OTBBNzQiLCJjaWQiOiJpbmdlc3Rvci5ERTZCNzE4NDI4MjQ0Q0YyQTQwOUYzRjBFRTU5MEE3NCIsImF6cCI6ImluZ2VzdG9yLkRFNkI3MTg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VYztjrBqHGZkKt2DvdtU0RtXAkgc-qFUo2ToMQj86hqc80OhiIb_2mnXOOWZswrrfxPizgk9zL22-i6a00LGsptJZ2ErCDSmpGBka6h6H-N8vVWTsOhx_nnp7jUHKGZOZQjcsqSIWwRosIE_G6kgGMpL2L_bLgDVpZiQ3Ri19K5J7co1y4TqjMF3kvXb0rOdIJsDO1PCfMztAazlw",
  "expires_in": 86399,
  "scope": "openid",
  "jti": "5e2c90ea-9edd-4da1-80c8-4a0d67f77ef3"
}

What To Do Next

Use the obtained token for accessing, registering tenant resources and performing data ingestion for the tenant.