API call description
If you previously used:- Internal app: Called the Obtain the access token of an internal app API to obtain the credential for calling APIs of your organization.
- Third-party enterprise app: Called the Obtain the access token of the authorized enterprise API to obtain the credential for calling APIs on behalf of the enterprise that authorized the third-party app.
Request
| Basic information | |
|---|---|
| HTTP URL | https://api.dingtalk.io/v1.0/oauth2/{corpId}/token |
| HTTP Method | POST |
| Supported app types | appType-Internal app, appType-Third-party enterprise app |
| Permission requirements | permission-qyapi_base-Basic permission required to call enterprise APIs |
Path parameter
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| corpId | String | Yes | ding9f****41 | Organization ID. Enter the corpId of the organization in which the app runs: - Internal app: Enter the corpId of your organization. - Third-party enterprise app: Enter the corpId of the authorized enterprise that has enabled the app. |
Request body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| client_id | String | Yes | suite123 | The ClientID of the app. |
| client_secret | String | Yes | ******** | The ClientSecret of the app. |
| grant_type | String | Yes | client_credentials | Grant type: client_credentials |
Request example
HTTPResponse
Response body
| Name | Type | Example | Description |
|---|---|---|---|
| access_token | String | 2bf******9be361a5084f1e2b8 | Access credential. |
| expires_in | Integer | 7200 | Validity period of the access credential, in seconds. |
Response body example
Error codes
If an error occurs when you call this API, refer to the Global error codes document to find a solution based on the error message.| HttpCode | Error code | Error message | Description |
|---|---|---|---|
| 400 | invalid.client | invalid.client | Invalid ClientID or ClientSecret. |
| 400 | unsupported.grant.type | unsupported.grant.type | This grant type is not supported. Check the grant type parameter. |
| 401 | unauthorized.client | unauthorized.client | The app is not authorized. |
| 500 | server.error | server.error | Unexpected server error. |