Get Access Token

Access Token is used to verify an authenticated API call. The third-party application needs to request for an access token and carry the access token in every request to access the API.

Prerequisites

You have enabled the API feature on the Yeastar P-Series Software Edition. For more information, see Enable Yeastar P-Series Software Edition API.

Request URL

POST {base_url}/{api_path}/get_token

Request Parameters

Important: You MUST include a User-Agent header with every request that you submit to the Yeastar P-Series Software Edition API, so that the PBX can identify your application and respond to the request. For example, User-Agent: OpenAPI.
Parameter Required Type Description
username Yes String User name.

You can obtain the username from the Client ID on PBX web portal.

password Yes String Password.

You can obtain the password from the Client Secret on PBX web portal.

Response parameters

Parameter Type Description
errcode Integer Returned error code.
  • 0: Succeed.
  • Non-zero value: Failed.
Note: You can check the error code and error message in Error Code and Error Message.
errmsg String Returned message.
  • SUCCESS: Succeed.
  • FAILURE: Failed.
access_token_expire_time Integer Access token expire time. (Unit: second)
access_token String Credential of calling API interfaces. All requests to call API interfaces must carry an access token.
refresh_token_expire_time Integer Refresh token expire time. (Unit: second)
refresh_token String Refresh token.

refresh_token can be used to obtain new access_token and refresh_token.

Examples

Request example
POST /openapi/v1.0/get_token
Host: 192.168.5.150:8088
Content-Type: application/json
User-Agent: OpenAPI
{
	"username": "UEnH9Dmv6uBJEXsYcag1trNfQThYXXXX",
	"password": "ZLcXl63S9EtMnYoHUnjbVo6sA8CbXXXX"
}
Response example
HTTP/1.1 200 OK
{
    "errcode": 0,
    "errmsg": "SUCCESS",
    "access_token_expire_time": 1800,
    "access_token": "EXZMpZAO86mbrKm6rFtgeb3rfcpC9uqS",
    "refresh_token_expire_time": 86400,
    "refresh_token": "SCduGecwbG9jIusiS8FxFUVn3kf0Q9R8"
}