Authorization

To use Oz API, you require authorizing via the Authorize method. This method allows obtaining the necessary data to interact with the API. To execute this method, send the following data to the API server via a POST request:

Header:

  • Host: API server address

The request body, in the credentials block:

  • “email”: “user login”,
  • “password”: “user password”.

Please request the API server address and credentials from us.

Example of running the Authorize method:

HTTP

Bash

Python

PHP

Java

                POST /api/authorize/auth HTTP/1.1
Host: host_address
Content-Type: application/json
User-Agent: PostmanRuntime/7.15.2
Accept: */*
Cache-Control: no-cache
Postman-Token: postman_token
Host: host_address
Accept-Encoding: gzip, deflate
Content-Length: 91
Connection: keep-alive
cache-control: no-cache

{
  "credentials": {
    "email": "user_email",
    "password": "user_password"
  }
}


            
                curl -X POST \
  https://host_address/api/authorize/auth \
  -H 'Accept: */*' \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Length: 91' \
  -H 'Content-Type: application/json' \
  -H 'Host: host_address' \
  -H 'Postman-Token: postman_token' \
  -H 'User-Agent: PostmanRuntime/7.15.2' \
  -H 'cache-control: no-cache' \
  -d '{
  "credentials": {
    "email": "user_email",
    "password": "user_password"
  }
}'


            
                import requests

url = "https://host_address/api/authorize/auth"

payload = "{\n\t\"credentials\": {\n\t\t\"email\": \"user_email\",\n\t\t\"password\": \"user_password\"\n\t}\n}"
headers = {
    'Content-Type': "application/json",
    'User-Agent': "PostmanRuntime/7.15.2",
    'Accept': "*/*",
    'Cache-Control': "no-cache",
    'Postman-Token': "postman_token",
    'Host': "host_address",
    'Accept-Encoding': "gzip, deflate",
    'Content-Length': "91",
    'Connection': "keep-alive",
    'cache-control': "no-cache"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)


            
                setUrl('https://host_address/api/authorize/auth');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'Connection' => 'keep-alive',
  'Content-Length' => '91',
  'Accept-Encoding' => 'gzip, deflate',
  'Host' => 'host_address',
  'Postman-Token' => 'postman_token',
  'Cache-Control' => 'no-cache',
  'Accept' => '*/*',
  'User-Agent' => 'PostmanRuntime/7.15.2',
  'Content-Type' => 'application/json'
));

$request->setBody('{
  "credentials": {
    "email": "user_email",
    "password": "user_password"
  }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}


            
                OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"credentials\": {\n\t\t\"email\": \"user_email\",\n\t\t\"password\": \"user_password\"\n\t}\n}");
Request request = new Request.Builder()
  .url("https://host_address/api/authorize/auth")
  .post(body)
  .addHeader("Content-Type", "application/json")
  .addHeader("User-Agent", "PostmanRuntime/7.15.2")
  .addHeader("Accept", "*/*")
  .addHeader("Cache-Control", "no-cache")
  .addHeader("Postman-Token", "postman_token")
  .addHeader("Host", "host_address")
  .addHeader("Accept-Encoding", "gzip, deflate")
  .addHeader("Content-Length", "91")
  .addHeader("Connection", "keep-alive")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();


            

The API server returns your authorization token and user data in the JSON format.

  • “access_token”: “********”

Without a token, you won’t be able to interact with the Oz API. Almost all requests require authorization; make sure to include the authorization token in the header of the HTTP request.

Example of server’s full response:

JSON

                {
    "technical_meta_data": {},
    "session_id": 1111111,
    "user_id": "your user id",
    "access_token": "the access token generated based on your credentials",
    "expire_token": "the expiration token",
    "expire_date": 111.111, // the time when the token is going to expire
    // the information on the device from which the request has been sent
    "device_info": {
        "device_family": "{{device_family}}", 
        "device_platform": "{{device_platform}}", 
        "device_os": "{{device_os_version}}",
        "app_version": "{{app_version}}",
        "app_build": null,
        "device_locale": null,
        "sdk_version": "{{sdk_version}}",
        "sdk_build": null,
        "bundle_id": "{{sdk_bundle_id}}"
    },
    "old_access_token": null, //the information on the older access token if it existed
    "user": {
        "technical_meta_data": {},
        "meta_data": {},
        "user_id": "your user id",
        "user_type": "your user role",
        "first_name": "user first name",
        "last_name": "user last name",
        "middle_name": "user middle name",
        "email": "user email",
        "is_active": true,
        "can_start_analyse_biometry": true,
        "can_start_analyse_collection": true,
        "can_start_analyse_documents": true,
        "can_start_analyse_quality": true,
        "company_id": " the company this user belongs to"
    }
}