> For the complete documentation index, see [llms.txt](https://docs.vaultid.com.br/workspace/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vaultid.com.br/workspace/cloud/api/autenticacao-de-usuarios/autenticacao-em-sistemas-web.md).

# OAuth2 -  Authorization Code

### Authorization Code Request

A aplicação que está realizando a integração deve redirecionar o usuário para uma URL construída no seguinte formato:<br>

Parâmetros da requisição (na query string, método GET):

<mark style="color:blue;">`GET`</mark> `https://api.birdid.com.br/v0/oauth/authorize`

#### Query Parameters

| Name                                                                              | Type   | Description                                                                                                                                                                                                                                           |
| --------------------------------------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| login\_hint                                                                       | string | <p>Valor de CPF ou CNPJ a ser informado como filtro para seleção do certificado a ser utilizado.<br>Por ser do tipo string, preencha com zeros à esquerda (11 dígitos para CPF e 14 dígitos para CNPJ).</p>                                           |
| code\_challenge\_method                                                           | string | Fixo: "S256", veja RFC 7636                                                                                                                                                                                                                           |
| code\_challenge                                                                   | string | Veja RFC 7636                                                                                                                                                                                                                                         |
| response\_type                                                                    | string | Fixo: "code".                                                                                                                                                                                                                                         |
| client\_id                                                                        | string | Deve ter a identificação da aplicação.                                                                                                                                                                                                                |
| redirect\_uri                                                                     | string | Deve ter a URI para redirecionar o usuário de volta para a aplicação de origem. A URI deve estar na lista de URI's autorizadas para a aplicação. Deve ser URL ENCODED. Se não informado, será considerada a primeira URI cadastrada para a aplicação. |
| state                                                                             | string | É retornado sem modificações para aplicação de origem.                                                                                                                                                                                                |
| lifetime                                                                          | number | Indica o tempo de vida desejado para o token de autorização. Inteiro, em segundos.                                                                                                                                                                    |
| [scope](https://docs.vaultid.com.br/workspace/cloud/api/autenticacao-de-usuarios) | string | Se não informado, será considerado "authentication\_session".                                                                                                                                                                                         |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

O usuário será redirecionado para página da solução onde as credenciais deverão ser informadas, após a devida autenticação e autorização o usuário é redirecionado para a página apontada pelo cliente da solução.<br>

Retorno:

O usuário é redirecionado para redirect\_uri com dois parâmetros na query string: code (o código de autorização a ser usado na solicitação do token) e state (da mesma forma que informado na requisição inicial).<br>

### **Exchange Code for Access Token**

Após o usuário ser direcionado de volta para aplicação de origem, a aplicação que está realizando a integração deverá consumir em background o endpoint para recuperar o token OAuth.<br>

Parâmetros da requisição:

<mark style="color:green;">`POST`</mark> `https://api.birdid.com.br/v0/oauth/token`

#### Headers

| Name         | Type   | Description      |
| ------------ | ------ | ---------------- |
| Content-Type | string | application/json |
| Accept       | string | application/json |

#### Request Body

| Name           | Type   | Description                                                                      |
| -------------- | ------ | -------------------------------------------------------------------------------- |
| code\_verifier | string | Veja RFC 7636                                                                    |
| redirect\_uri  | string | URL de redirecionamento                                                          |
| client\_id     | string | Deve ter a identificação da aplicação.                                           |
| client\_secret | string | Deve ter o secret da aplicação                                                   |
| code           | string | Deve ter o code                                                                  |
| grant\_type    | string | Fixo: "authorization\_code"                                                      |
| lifetime       | number | Indica o tempo de vida desejado para o token a ser gerado. Inteiro, em segundos. |

{% tabs %}
{% tab title="200 " %}

```
{
	"access_token": "b923575f1ced0ee732ee274b2e02784040bd9606",
	"expires_in": 300,
	"token_type": "Bearer",
	"authorized_identification_type": "CPF",
	"authorized_identification": "00000000001"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.vaultid.com.br/workspace/cloud/api/autenticacao-de-usuarios/autenticacao-em-sistemas-web.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
