Get an Access Token

The third-party application must first request an access token, then includes the access token in every request to access the Yeastar Workplace API.

Prerequisites

You have enabled API feature on Yeastar Workplace, and obtained the Client ID and Client Secret.

Request URL

POST {base_url}/services/openapi/v1.0/authentication/get_token

Request parameters

Body parameters

Parameter Required Type Description
client_id Yes String Client ID.

You can obtain the Client ID on Yeastar Workplace admin portal.

client_secret Yes String Client secret.

You can obtain the Client Secret on Yeastar Workplace admin portal.

Response parameters

Parameter Type Description
access_token String The authentication credential for API calls. All API requests must include an access token.
Note: If the access token is compromised, you can regenerate the Client Secret on Yeastar Workplace admin portal and request a new one, and the previous one will be invalidated automatically.
refresh_token String Refresh token, which can be used to refresh an access token.
expires_in Integer The remaining validity period of the access token (Unit: second).

Examples

Request example

Request an access token with Client ID and Client Secret.

POST /services/openapi/v1.0/authentication/get_token HTTP/1.1
Host: workplace.yeastar.com
Content-Type: application/x-www-form-urlencoded

client_id=79568aa0-xxxx-xxxx-xxxx-79a16d73472a&client_secret=rLZN4Uocxxxxd5ZVyQgS4GcAbZD1

Response example

HTTP/1.1 200 OK
{
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJncmFudF90eXBlIjoiY2xpZW50X2NyZWRlbnRpYWxzIiwic2NvcGUiOlsiL29wZW5hcGkvIl0sImVudGVycHJpc2VfaWQiOjEwMDQzMywicmVnaW9uIjoiR0wiLCJhdXRob3JpdGllcyI6WyJST0xFX0NMSUVOVCJdLCJqdGkiOiJjODA0ZDNhNy1mYWU2LTRmYWQtYmExMi1kNDQ0MGJjYzBiMjMiLCJjbGllbnRfaWQiOiI3OTU2OGFhMC0wYjBkLTQyZjYtOGRiNC03OWExNmQ3MzQ3MmEiLCJ0cyI6MTY4OTczNjk1NCwiZXhwX2luIjo4NjQwMH0.EybcV1rsw9oPoYd4vfLkfLbCKRobiXYXyyP80RDrghM",
    "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJncmFudF90eXBlIjoiY2xpZW50X2NyZWRlbnRpYWxzIiwic2NvcGUiOlsiL29wZW5hcGkvIl0sImF0aSI6ImM4MDRkM2E3LWZhZTYtNGZhZC1iYTEyLWQ0NDQwYmNjMGIyMyIsImVudGVycHJpc2VfaWQiOjEwMDQzMywicmVnaW9uIjoiR0wiLCJhdXRob3JpdGllcyI6WyJST0xFX0NMSUVOVCJdLCJqdGkiOiI2ZDRkMGFhMi0wYWY4LTQ5NTctOWFkYS1hOWM4ZmFhMDc4ODciLCJjbGllbnRfaWQiOiI3OTU2OGFhMC0wYjBkLTQyZjYtOGRiNC03OWExNmQ3MzQ3MmEiLCJ0cyI6MTY4OTczNjk1NCwiZXhwX2luIjo4NjQwMH0._ifT5MqC0Fvl1hIeLeTUZCowYYa8goQjzBYXLu8mbfY",
    "expires_in": 86399
}