Authentication

The EDM API requires access via an access token generated through the API Key. Use the EDM Operations Dashboard to generate the API Key. Assign roles to the API Key. Based upon these assigned roles the API Key can invoke a set of APIs.

More details about the roles and what actions is allowed with a particular role is described here https://developer.cisco.com/docs/iotod/#!add-and-manage-users/built-in-roles

When you authenticate using the /auth/token API, you receive an authorization token. Use the authorization token, which you must then include in the request of each subsequent API operation.

An API key is a unique identifier that is assigned to an individual or application using an API. An API Key can have different levels of roles and access and are typically used for authentication purposes. An access token is a more specific type of credential that is issued to authorize applications after successful authentication and are used to access protected resources on an API. As our application is based upon multi-organization architecture, it is used for identifying the organization for whom the API call is being made.

API Key Creation

When generating an API Key, select the Roles and Expiration period/duration.

  1. Log in to IoT Operations Dashboard and click the "people icon" on the far right of the header. Click Access Control.
  2. Click the API Key tab. Click Generate API Key.

API Key Name

  1. Enter the API key Name, select Role and Expiration time/duration and click Generate.

  2. Copy the API Key Secret.

    IMPORTANT: Do not navigate away from this screen before copying the API key; you cannot view it again.

Generate API Key

Steps to Generate Access Token

Send a POST request to the following URL. Use the following json content in the request body to get the access_token. Use the token to invoke the EDM NB APIs.

NOTE: NB means Northbound.

POST {{Cluster URL}}/nbapi/iam/v1/auth/token

For Example:

POST https://us.ciscoiot.com/nbapi/iam/v1/auth/token

JSON Request Body

{
    "client_id": "{insert organization name}->{insert API key name}",
    "client_secret": "{insert API key secret}",
    "grant_type": "client_credentials"
}

NOTES:

  • You must enter the organization name and the API key name in the client_id field in lower case only.
  • You must retain the existing spaces.
  • You can also find this value under the API Key ID column in the API Key page.
  • client_id in upper case is not valid.

Example JSON:

{
    "client_id": "cisco->my api key",
    "client_secret": "!Fj?qAS$Rc-ct=W",
    "grant_type": "client_credentials"
}

Access Token Response

{
    "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJaYXdEQnRBcjlEbF8zSGhLTy1vMUZQXzhzZE8yc01xZzYwUHdGdW9JSzlVIn0.eyJleHAiOjE2ODYxMjA0MjQsIm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-FxHJVAPVXpZuC0Bmca8vJhSssG-oAreIkm7wQ5KyoIwm-UDdgS82uOf5wzTzOxsRBXf2L9lmT3_dD-0yJef7ET1Twx3IWO3rqSDw4cnadouAyUVDH_vTdFza47v-rCyolV0qI1Ki_5CUPIi6FeJIxcHwdMh7hF6_ZAQ1HFS8v012aGa54NgqRGj9slXFlHLaUzM3N_KOMNdKCbVMUYiklYuPhWeqc5dh0R21lIX2zbplltvUFUG_Lcz-pv9EAhiLzE74ucwWSxAR2xvQ",
    "token_type": "Bearer",
    "expires_in": 300,
    "refresh_expires_in": 0
}

This gives the access_token. You must use this token for further API calls.

NOTE: access_token is valid for 300 seconds (5 minutes). Use it or generate a new token after 5 minutes.

Steps to fetch x-tenant-id

  1. Log in to IoT Operations Dashboard and click the "people icon" on the far right of the header. Click Access Control.

  2. Click the API Key tab and then copy the "Organization ID" from the UI and use it as the "x-tenant-id" in the http header for the API requests.

  3. This x-tenant-id is mandatory for each API call. Use it for each API call.

  4. After getting the access_token and the x-tenant-id, provide them in the header as key value pairs shown below:

    key:x-tenant-id, value:{{x-tenant-id}}
    key:Authorization, value:Bearer {{access_token}}
    

    Example:

    x-tenant-id 71724bda-56fg-8hnc-9065-98z255hgml4c
    Authorization Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJaYXdEQnRBcjlEbF8zSGhLTy1vMUZQXzhzZE8yc01xZzYwUHdGdW9JSzlVIn0.eyJleHAiOjE2NzkyOTY0MjIsImlhdCI6MTY3OTI5NjEyMiwianRpIjoiMzY5NmEwYmItM2Y0Mi00YmMwLWFlMTgtNzg0MzNlY2Y2OGM0IiwiaXNzIjoiaHR0cHM6Ly9yYWluaWVyZGV2Mi5jaXNjb2lvdGRldi5pby9hdXRoL3JlYWxtcy9yYWluaWVyLWlhbSIsImF1ZCI6WyJsb2dpbi1hcHAiLCJhY2NvdW50Il0sInN1YiI6IjJiMWE2OGEwLTViMzgtNDA2Yi1hYWViLWUwNjA5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peLLg
    

NOTE: If Single-Sign On (SSO) is set up for an organization, create an API Key with the required roles to access the API instead of using user accounts.