Connection and Security

API Access Using Postman

The API is protected by an API key. Postman can be used during development to try out the API.

Postman Access Token Dialog

Access token parameters will be provided by Omocom, one set for Beta environment and one for Production environment. The location of the Beta API is at https://api-beta.omocom.se and will be used for all development and testing.

Parameter Value
Grant Type Client Credentials
Access Token URL https://login.microsoftonline.com/88410344-ec97-405b-81ab-2953d91044bc/oauth2/v2.0/token/
Client ID Provided by Omocom, for Beta and Prod respectively
Client Secret As above
Scope As above

Tokens are valid for two hours, after which time a new token must be fetched.

API Access Using Curl

Alternately, Curl can be used to request an API token using the following code (targeting the Beta environment in this case):

#!/bin/bash
ClientId="<assinged Client>"
Scope="https://api-beta.omocom.se/.default" 

PlatformId="<assigned platform ID>"
Market="se"

#
# Utilities
#
getJsonValue() {
  python -c "import sys, json; print(json.load(sys.stdin)[\"$1\"])"
}

#
# Authenticate
#
HTTP_STATUS=$(curl -w "%{http_code}" -o .response -s -X POST --location "https://login.microsoftonline.com/88410344-ec97-405b-81ab-2953d91044bc/oauth2/v2.0/token" --http1.1 \
    -H "Content-type: application/x-www-form-urlencoded" \
    -d "grant_type=client_credentials 
     &client_id=$ClientId 
     &client_secret=$ClientSecret 
     &scope=$Scope") 
>&2 echo "Authenticate => $HTTP_STATUS"

if [ "$HTTP_STATUS" != "200" ]; then
    cat .response
    exit
fi

TOKEN=$(cat .response | getJsonValue "access_token")