# How do I authenticate to my AvaTax Brazil account?

Source: https://developer.avalara.com/services-calculation-en/authentication/how_do_i_authenticate_to_my_avatax_account/

# How do I authenticate to my AvaTax Brazil account?

At this session, you will see all the necessary steps to create a token and authenticate it in our API.

The Authentication uses OAuth 2.0 method, which means that an access token will be received to allow access to the application for each call with the credentials obtained.

This “Access Token” has a specific period, and it is necessary to send the credentials again to obtain new access once it expires.

It is possible to renew the “Access Token”, or to send the credentials on each new call, but the second way is usually indicated only in cases of an unsafe environment, such as GUIs.

## Create an API access token through the Avalara Portal

The entire process for creating the token and the credentials required to access an access token are made through the Avalara Portal. Once logged in to the Avalara Portal, follow the instructions below.

Access the portal at the following URL: [https://portal.sandbox.avalarabrasil.com.br/Login](https://portal.sandbox.avalarabrasil.com.br/Login)

1.  Click `configurações` (configuration).
2.  And then click `tokens de assinatura` (signature tokens).
3.  Select `novo token de assinatura` (new signature token) option.

![](https://www.avalara.com/content/dam/assets/ui/screenshots/token_avatax_br.png)

**Generate a new token:**

1.  Choose a name in the name field (nome).
2.  Select a start date in the start date field (Data início DD/MM/YYYY).
3.  Select an end date in the end date field (Data fim DD/MM/YYYY).
4.  Press Save.

![](https://www.avalara.com/content/dam/assets/ui/screenshots/token_2_avataxbr.png)

A new window opens with the`token information` (informações do token).

-   On the signature field (`assinatura`), the value that should be sent in the tag "`client_id`" appears.
-   On the secret token field (`segredo do token`), the value that should be sent in the tag  "`client_secret`" appears

Attention: Ensure that you save the token in a safe place before you conclude the process. It won't be possible to retrieve it again.

1.  Press "yes, I've saved the token secret in a safe place" (`sim, guardei o segredo do token em segurança`) button.
2.  Click (`fechar`) to close.

![](https://www.avalara.com/content/dam/assets/ui/screenshots/token3_avataxbr.png)

**Advice:** _Following best practices, we recommend that each application connecting to our solution use a separate Authentication Token._

### Get an Access Token

Now that you successfully created the necessary credentials inside our Portal, you just need to call our API, and then get an access token.

Mandatory fields

Attributes

Description

Mandatory

grant\_type

To request an initial “`Access Token`”, you must send the “`client_credentials`” value.

Mandatory

client\_id

This is equivalent value to “`subscription ID`”.

Mandatory

cliente\_secret

The unique token (`secret`) provided during token creation on the Avalara Portal.

Suggested

disableTokenRefresh

This property indicates whether or not the session requester wants to obtain the “`RefreshToken`” to renew the session every “X” minutes.

If the applicant chooses to keep the session active until the expiration in “X” hours, without periodic renewal, then a fixed amount must be sent as “`true`” and the “`RefreshToken`” **WILL NOT BE RECEIVED**.

Request Model:

POST: [https://api-gateway.sandbox.avalarabrasil.com.br/portal/health](https://api-gateway.sandbox.avalarabrasil.com.br/portal/health)

```
{ "grant_type": "client_credentials", "client_id": "", "client_secret": "", "disableTokenRefresh": true}
```

**Advice:** _This process must be repeated until the session expires. This expiration information can be verified in the body's response tag named: "`expires_in_session`", and once it expires, you must start the process from the beginning._ 

[Previous](/for-review-only/en/leila-paul/services-calculation-en/authentication/avatax_brazil_authentication)

[Next](/for-review-only/en/leila-paul/services-calculation-en/authentication/how_do_i_get_access_to_sandbox)