Smart+Connected Digital Platform API - Authentication and API Access

Objectives

  • Understand Smart+Connected Digital Platform Authentication. Use the Smart+Connected Digital Platform Login API to retrieve access tokens required for other Smart+Connected Digital Platform API Requests.
  • Understand how to make a Smart+Connected Digital Platform API Request to a resource requiring access tokens. Make an additional Smart+Connected Digital Platform API Request to retrieve more information about the current user.
  • Walk through a sample application demonstrating how to authenticate with the Smart+Connected Digital Platform and retrieve, and use, the access tokens from a Python script.

You can download the complete sample code project for this lab on GitHub: CiscoDevNet/scc-cdp-api-examples

Overview

Cisco Smart+Connected Digital Platform is a platform providing a rich API for retrieving information from connected cities and device collections. This includes sensor data as well as information about users, locations and capabilities of the current instance of the Cisco Smart+Connected Digital Platform. The API provides access to both real time and historical data from the connected sensors and devices.

All Smart+Connected Digital Platform APIs (except authentication) require access tokens. Before any of these APIs can be used, you must authenticate with Smart+Connected Digital Platform to get the tokens needed to make successful calls.

You can find documentation other information on the Cisco Smart+Connected Digital Platform DevNet Site

In order to complete this lab, you will need to make a reservation to access the Smart+Connected Digital Platform sandbox instance. You can make a reservation on the Cisco Smart+Connected Digital Platform DevNet sandbox page.

Smart+Connected Digital Platform API Requirements

All Smart+Connected Digital Platform APIs, other than authentication, are protected and require two access tokens in order to use them and retrieve data. These tokens are:

  1. api_access_token
  2. app_access_token

Application developers integrating with the Smart+Connected Digital Platform API must register their app via the Cisco Smart+Connected Digital Platform API Developers portal. During registration, the system generates a Client ID and Client Secret pair, which are later used by the application to access the Smart+Connected Digital Platform API authentication service. During this lab, you use the provided Client ID and Secret, along with the provided Smart+Connected Digital Platform username and password, to authenticate and make an additional Smart+Connected Digital Platform API Request.

We will examine a small sample Python script that demonstrates how to perform Smart+Connected Digital Platform API authentication. We'll walk through some of the key concepts and code details, then use the access tokens returned by the authentication call to make another Smart+Connected Digital Platform API Request.

Lab Overview

This Learning Lab is comprised of two API calls each with two main steps:

  1. Authenticate
    • Authenticate using the /login Smart+Connected Digital Platform API by making a POST Request and submitting the required data in the post body
    • Parse the response to get the two tokens needed for all other API requests
  2. Retrieve User Information
    • Make a GET Request to the /accounts/username Smart+Connected Digital Platform API
    • Parse the response to get the userid and customerid for the current user. These are required by some of the other Smart+Connected Digital Platform APIs and will be used in the next Learning Lab