Request Access Token
Before your application can successfully request a YCM API, it must obtain an access token that grants access to the API.
Prerequisites
Enable YCM API on Yeastar Central Management and obtain the API Credentials.
For more information, see Enable YCM API.
Request URL
POST {base_url}/dm/open_api/oauth/token
Request parameters
Note: You MUST include a User-Agent header with every
request that you submit to the YCM API, so that the Yeastar Central Management can
identify your application and respond to the request. For example,
User-Agent: OpenAPI
.Parameter | Required | Type | Description |
---|---|---|---|
grant_type | Yes | String | Authorization grant type, the value is
client_credentials . |
client_id | Yes | String | Client ID. Obtain the Client ID from the YCM web interface. |
client_secret | Yes | String | Client Secret. Obtain the Client Secret from the YCM web interface. |
Response parameters
Parameter | Type | Description |
---|---|---|
access_token | String | A token that can be used to access a YCM API. |
refresh_token | String | Refresh token, which can be used to refresh an access token. |
token_type | String | Identify the type of token returned. For YCM API, this
field always has the value
|
expires_in | Integer | The remaining lifetime of the access token. Time Unit: second. |
jti | String | A JWT(JSON Web Token) that contains identity information of the access token and refresh token. |
Examples
Request example
POST /dm/open_api/oauth/token HTTP/1.1
Host: ycm.yeastar.com
User-Agent: OpenAPI
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_id=kp9yyntmueXXXXXXXXX&client_secret=Z7wC807wK9zR77FCOqsVXXXXX
Response example
HTTP/1.1 200 OK
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjdXN0b21Kd3RQYXlsb2FkSW5mbyI6eyJncmFudFR5cGUiOiJjbGllbnRfY3JlZGVudGlhbHMiLCJ5c0lkIjoxNzg5NjM2MDM5MDg1MDI1NzM0OSwicmVmcmVzaFZlcnNpb24iOjE2Mzg5NTcxNTJ9LCJzY29wZSI6WyJhbGwiXSwiZXhwIjoxNjM4OTU4OTUyLCJhdXRob3JpdGllcyI6WyJST0xFX0NMSUVOVCJdLCJqdGkiOiJiZjQ1YmUyYy0yOGFhLTQ3OTUtYmQ4MS03YzBjZjZiYWMxMmMiLCJjbGllbnRfaWQiOiJrcDl5eW50bXVlc3V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