These docs are for v1.0. Click to read the latest docs for v2.0.

This page describes how to authenticate to the SafeStream API

Authenticating to SafeStream requires an authentication token. An authentication token is a temporal token that permits you to make requests to the SafeStream API. It will look like this:

eyJ0eXAifertV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2Nlc3NLZXkiOiI1MWYzMzk5OC1kZGJmLTRjNGMtYjg5OC1mMmQzZjBhNDhiNDQiLCJzY29wZSI6IjI4NjE2ODEzLWQ1YzUtNDJmMC1i4k9mLTAwMmRjZGM0NzgxOSIsInVzboikr75j0sE3YzM2ZDZjLWM0YjItNGIyYi04Yj5k8WQxMDFjMmFiNDA3MiIsImNsaWVudENyeG0pR5j9rh86IkFZeDJPREhIRjRiWkJuNWNET0diMkI2UDZBQjNHZnhQTHBTclZ5KzBZeWM9IiwiaWF0IjoxNDYyNTQzODk2fQ.wtdf9lRW_vPZ_AM1IcxIFVju7Ng3kiDDtf084jxm9tl

In order to obtain an authentication token you should use your API key and client id. The following is an example of how you can get an authentication token using your API key and client id.

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.safestream.com/1.0/authenticate/accessToken",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "x-api-client-id: YOUR_CLIENT_ID",
    "x-api-key: YOUR_API_KEY"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
var client = new RestClient("https://safestream.shiftplatform.io/1.0/authenticate/accessToken");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-client-id", "YOUR_CLIENT_ID");
request.AddHeader("x-api-key", "YOUR_API_KEY");
IRestResponse response = client.Execute(request);
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://safestream.shiftplatform.io/1.0/authenticate/accessToken")
  .get()
  .addHeader("x-api-key", "YOUR_API_KEY")
  .addHeader("x-api-client-id", "YOUR_CLIENT_ID")
  .build();

Response response = client.newCall(request).execute();
curl -X GET -H "x-api-key: YOUR_API_KEY" -H "x-api-client-id: YOUR_CLIENT_ID" "https://safestream-api.shiftplatform.io/1.0/authenticate/accessToken"

📘

From This Point Forward Use Your Auth Token

Your API key and client id are just used to get an authentication token. You'll use your authentication token for all other requests to the SafeStream API.

Once you have your auth token you can begin making requests to the SafeStream API. Requests using your authentication token will look slightly different. Instead of sending your API key and client ID with each request you will send your authentication token in the authorization header. Here's an example:

GET /1.0 HTTP/1.1
Authorization: Bearer YOUR_AUTH_TOKEN

🚧

The SafeStream API is Stateless

Each API call needs to contain the authentication token. The authentication token permits full access to the SafeStream API. Keep it safe.