# Request access token

Source: https://developer.avalara.com/products/e-invoicing/integration-guides/elr/mei2825261918480/

Guide: E-Invoicing and Live Reporting

# Request access token

Learn how to generate client credentials and use them to authenticate ELR API requests.

Endpoint: `POST /connect/token`

This endpoint requires you to send the `client_id` and `client_secret` credentials as part of the `URL-encoded` request body. Include a `grant_type` property with the value `client_credentials`.

The response includes the `access_token` which is used for all other requests.

Don't call the `requestToken` endpoint before every single request!

You could implement either of the following approaches:

1.  Track the session age in your own implementation. An example script that uses the `expires_in` value from the response to this request for that purpose is included in the prerequest script at collection level, OR
2.  Wait until you get a 401 status code from any further endpoints and retry those requests after getting a new `access_token`.

## Example request

```
curl --location '/connect/token' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=Retrieve from {{appUrl}}/elr/integrations' \
--data-urlencode 'client_secret=•••••••'
```