> For the complete documentation index, see [llms.txt](https://dar-open-network.gitbook.io/developers/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dar-open-network.gitbook.io/developers/dar-id/authentication/2.-exchange-code-for-access-token.md).

# 2. Exchange Code for Access Token

#### **Endpoint:**

```
POST <https://$>{AUTH_DOMAIN}/oauth2/token
Content-Type: application/x-www-form-urlencoded

```

#### **Parameters:**

| Parameter      | Type   | Description                         |
| -------------- | ------ | ----------------------------------- |
| client\_id     | string | Your DAR ID client ID               |
| client\_secret | string | Your DAR ID client secret           |
| code           | string | The code received from step 1       |
| grant\_type    | string | Must be "authorization\_code"       |
| redirect\_uri  | string | Must match the URI from step 1      |
| code\_verifier | string | Required if PKCE was used in step 1 |

#### **Example Request:**

```bash
curl -X POST ${AUTH_DOMAIN}/oauth2/token \\\\
  -H "Content-Type: application/x-www-form-urlencoded" \\\\
  -d "client_id=${CLIENT-ID}&client_secret=${CLIENT-SECRET}&code=${CODE}&grant_type=authorization_code&redirect_uri=${REDIRECT-URI}"

```

#### **Response:**

```json
{
  "access_token": "${access_token}",
  "expires_in": 86400,
  "refresh_token": "${refresh_token}",
  "scope": "Read",
  "token_type": "Bearer"
}
```
