Create an OAuth token for a stream: Auth.CreateAccessToken

Generates an access token for stream playback when using private authorization.

Parameters

params: object


params.camera: Uid aka string

Pattern: ^[a-zA-Z0-9_-]+$

Unique identifier used throughout the system

Unique stream identifier for which to generate the access token


params.stream: Uid aka null|string

optional nullable

Pattern: ^[a-zA-Z0-9_-]+$

Unique identifier used throughout the system

Unique stream identifier within the installation


params.ttl: integer

optional

Default:

JSON
3600

Token lifetime in seconds (0 = unlimited, not recommended)


params.live: boolean

optional

Default:

JSON
true

Allow live viewing


params.copy: boolean

optional

Default:

JSON
true

Allow DVR downloading


params.view: boolean

optional

Default:

JSON
true

Allow DVR viewing


params.from: null|integer

optional nullable

Default:

JSON
0

DVR time range lower bound in seconds (0 = unlimited)


params.to: null|integer

optional nullable

Default:

JSON
0

DVR time range upper bound in seconds (0 = unlimited, must be >= from)


params.whitelist: array

optional

Default:

JSON
[]

List of IP addresses allowed access without authentication

IP whitelist for unauthorized access

params.whitelist...

params.whitelist[]: IpAddress aka string

Pattern: ^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$|^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$

IPv4 or IPv6 address



Result

result: string


POST /api/

JSON
{
  "jsonrpc": "2.0",
  "method": "Auth.CreateAccessToken",
  "params": {
    "ttl": 3600,
    "camera": "camera_uuid",
    "stream": "stream_uuid",
    "live": true,
    "copy": true,
    "view": true,
    "from": 0,
    "to": 0,
    "whitelist": [
      "89.0.142.86",
      "89.0.142.86"
    ]
  },
  "id": 123
}
cURL
Bash
curl -k --request POST \
    --url 'https://your-domain/api/' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <api-authorization-token>' \
    --data '{
  "jsonrpc": "2.0",
  "method": "Auth.CreateAccessToken",
  "params": {
    "ttl": 3600,
    "camera": "camera_uuid",
    "stream": "stream_uuid",
    "live": true,
    "copy": true,
    "view": true,
    "from": 0,
    "to": 0,
    "whitelist": [
      "89.0.142.86",
      "89.0.142.86"
    ]
  },
  "id": 123
}'

200 OK

JSON
{
  "jsonrpc": "2.0",
  "result": "your_access_token",
  "id": 123
}

400 Bad Request

JSON
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32601,
    "message": "Method not found"
  },
  "id": 123
}

500 Internal Server Error

Server error