Help Center/ KooPhone/ API Reference/ APIs/ Instance Usage/ Obtaining device_token Before Streaming
Updated on 2024-07-22 GMT+08:00

Obtaining device_token Before Streaming

Function

This API is used for the tenant instance to obtain device_token before streaming. Before calling this API, ensure that the tenant has purchased a KooPhone cloud phone instance. The obtained device_token of the cloud phone instance is used as the authentication information and carries device_id to call the signaling address (signaling_url) in the response parameter.

URI

POST /v1/instances/{instance_id}/auth

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

instance_id

Yes

String

Instance ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

x-auth-token

Yes

String

IAM token information of the tenant.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

data

data object

All response parameter information.

error_code

String

Error code. 0 indicates success.

error_msg

String

Error message.

Table 4 data

Parameter

Type

Description

resource

resource object

Resource set.

device_token

String

Device authentication token.

Table 5 resource

Parameter

Type

Description

sdk

sdk object

SDK information.

rtc

rtc object

RTC information.

device_id

String

Device ID.

kp_id

String

Cloud phone instance ID, for example, whklpuo1.

Table 6 sdk

Parameter

Type

Description

internal

internal object

Internal network information.

external

external object

External network information.

Table 7 internal

Parameter

Type

Description

address

String

Internal IP address.

aport

String

Audio port.

atype

String

Audio type.

address_ipv6

String

IPv6 address.

Table 8 external

Parameter

Type

Description

address

String

External EIP.

aport

Integer

Audio port.

atype

Integer

Audio type.

address_ipv6

String

External IPv6 address.

Table 9 rtc

Parameter

Type

Description

ice_signaling

ice_signaling object

ICE signaling information.

Table 10 ice_signaling

Parameter

Type

Description

signaling_url

String

Signaling service access address.

expired_time

String

Streaming duration. Unit: s.

ice_servers

Array of strings

ICE server.

Status code: 400

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Response code. The error code specification is KOOPHONE.API.0001, and the number increases in ascending order. If error_code is 0, the operation is successful.

error_msg

String

Response description.

Status code: 500

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Response code. The error code specification is KOOPHONE.API.0001, and the number increases in ascending order. If error_code is 0, the operation is successful.

error_msg

String

Response description.

Example Requests

POST API. The request URL carries the KooPhone instance purchased by the tenant and the tenant token.

/v1/instances/Q39YyZvI/auth

Example Responses

Status code: 200

OK

{
  "data" : {
    "resource" : {
      "sdk" : {
        "internal" : {
          "address" : null,
          "aport" : null,
          "atype" : null,
          "address_ipv6" : null
        },
        "external" : {
          "address" : "10.xx.xx.xxx",
          "aport" : 10030,
          "atype" : 1,
          "address_ipv6" : null
        }
      },
      "rtc" : {
        "ice_signaling" : {
          "signaling_url" : "http://xxxxxxxxxx",
          "expired_time" : null,
          "ice_servers" : [ ]
        }
      },
      "device_id" : "7b0cd026df8d495b8a65d628d7bec433",
      "kp_id" : "Q39YyZvI"
    },
    "device_token" : "dee5081f40c83ddea3ded91c387351e9"
  },
  "error_code" : "0",
  "error_msg" : "ok"
}

Status code: 400

Bad Request

{
  "error_code" : "string",
  "error_msg" : "string"
}

Status code: 500

Internal Server Error

{
  "error_code" : "string",
  "error_msg" : "string"
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

500

Internal Server Error

Error Codes

See Error Codes.