# api/v1/token

Use the `ap1/v1/token` endpoint to request an authorization token for the DT Growth Reporting API. Authorization tokens expire after one hour.

| Host URL | `https://reporting.digitalturbine.com` |
| -------- | -------------------------------------- |
| Method   | `POST`                                 |
| Endpoint | `/auth/v1/token`                       |
| Headers  | `Content-Type: application/json`       |

### Sample Authentication Request

```
 https://reporting.digitalturbine.com/auth/v1/token
```

```json
{
        "grant_type": "client_credentials",
        "client_id": "3ce66d885XXXXXXXXXXa3b752bb9000",
        "client_secret": "YtMvC7VYTQMQ7w9UCUaFXXXJnwVZnQqq00000yt8IIh2h8XFDuXXXXXXXXSS6XTrFWW4TkebCcMLJkrXSw5IurkearTJIDzUxsbiMXv8hb4T23MwN6eE7DDIthRFqDnhnuhiDlY2oPeaOjsMbzE8joZ5cs6tsySJz6uZXwJ-x3lcYaYbgXXXXXXXX3_hFeuXm-C7-me2V1MMs-ftJxTd5QbHoUhG3Q5anCWCW_pg8x3CL4yPGCbpWUDZfpdNPyyCT4rxCEb-VC0Bdqwe8N2GGn_VSFOwQYxa-yap2JuNSGJfl_ZURXXXXXXXXFe1GpHDn8pk7yYwQYIGAg"
}
```

| PARAMETER       | TYPE   | STATUS   | DESCRIPTION                                                                                             |
| --------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------- |
| `grant_type`    | string | Required | Type of credentials you are sending. When sending API Report credentials, specify `client_credentials`. |
| `client_id`     | string | Required | Your Reporting API ID that DT sends via encrypted email.                                                |
| `client_secret` | string | Required | Your Reporting API password that DT sends via encrypted email.                                          |

### Sample Authentication Responses

The Reporting API responds to with both successful and unsuccessful authentication token requests.

#### Successful Response

When an authentication request is successful, you receive the following response in JSON format:

```json
{
        "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NzAwMTY5MDAsImV4cCI6MTU3MDAyMDUwMCwiYXVkIjoic3BlZWRiYWxsIiwic3ViIjoiMjEwMjYzIn0.hDo1waTytSys_oRhFNUPqZPom26bL05rxgtSt3XYHqI",
        "tokenType": "bearer",
        "expiresIn": 3600
}
```

| RESPONSE PARAMETER | TYPE   | DESCRIPTION                                                                                         |
| ------------------ | ------ | --------------------------------------------------------------------------------------------------- |
| `accessToken`      | string | Access token required for Reporting API requests                                                    |
| `tokenType`        | string | Type of token issued.                                                                               |
| `expiresIn`        | number | Time in seconds that the token is valid. All tokens expire one hour after successful token request. |

#### Unsuccessful Response

When a token request is unsuccessful, the Reporting API returns the following response:

```json
{
  "error": "internal_server_error"
}
```

The following table provides possible errors that result in an unsuccessful response.

| HTTP STATUS CODE           | ERROR                    | CAUSE                                                                                                                                                                                                                                                             |
| -------------------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 405 (Method\_Not\_Allowed) | N/A                      | The request method is not `POST`                                                                                                                                                                                                                                  |
| 400 (Bad\_Request)         | 400 (Bad\_Request)       | Empty request body or incorrect `Content-Type` header                                                                                                                                                                                                             |
| 400 (Bad\_Request)         | invalid\_request         | <p>This error occurs for the following reasons:<br>- Error while parsing JSON request body<br>- Missing <code>grant\_type</code> parameter in the request<br>- Missing or invalid <code>client\_id</code><br>- Missing or invalid <code>client\_secret</code></p> |
| 400 (Bad\_Request)         | unsupported\_grant\_type | Invalid `grant_type`. Always specify `client_credentials`.                                                                                                                                                                                                        |
| 400 (Bad\_Request)         | invalid\_client          | <p>This error occurs for the following reasons:<br>- The requested credentials were not found<br>- The requested credentials are incorrect or cannot be recognized<br>- Your account has been disabled<br>- Your credentials have been revoked</p>                |
