---
updatedAt: 2024-11-21T17:34:19.000Z
agentTools:
  projectIndex: https://developer.truckstop.com/llms.txt
---

# How To Exchange an Authorization Code for Access/Refresh Tokens

```shell Shell
curl -X POST "https://api-int.truckstop.com/auth/token" ^
  -H "Content-Type: application/x-www-form-urlencoded" ^
  -H "Authorization: Basic <base64 encoded client_id:secret>" ^
  -d "grant_type=authorization_code&code=<auth_code>&redirect_uri=<redirect_uri>"
```

```json Response Example
{
    "access_token": "<access token>",
    "token_type": "bearer",
    "expires_in": 1199,
    "refresh_token": "<refresh token>",
    "claims": "[{userClaimName:ClaimValue},{userClaimName2:ClaimValue2},{...}]"
}
```

# Set up the request

{/* shell@1 */}

The base URL will be

[https://api-int.truckstop.com/auth/token](https://api-int.truckstop.com/auth/token)

# Set Headers

{/* shell@2,3 */}

Content-Type will be application/x-www-form-urlencoded

Authorization will be: basic base64 encoded clientID:clientSecret

# Set body fields

{/* shell@4 */}

There are three body fields that will need to be set.

1. grant\_type:  This should be set to authorization\_code

2. redirect\_uri:  This should be set to the same redirect URI used to obtain the authorization code

3. code: this will the the code obtained in the Obtain Authorization Code recipe