> For the complete documentation index, see [llms.txt](https://docs.caf.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caf.io/caf-docs/caf-product-guides-pt-br/guia-do-usuario/smart-auth/access-token.md).

# Token de acesso

Para usar o Smart Auth SDK, você precisará gerar dois tokens de acesso: um para o Smart Auth e outro para o Face Liveness. Esta página mostra as etapas de como criar as chaves, gerar os tokens de acesso e as formas recomendadas de fazer isso.

## **Obtendo suas chaves do Face Liveness**

Acesse [página de tutorial do token de acesso do SDK](https://docs.caf.io/caf-sdk/sdk_integration_documentation) para ver como gerá-lo.

## **Obtendo suas chaves do Smart Auth**

1. Acesse a [página de tokens do Smart Auth](https://identity.combateafraude.com/tokens);
2. Se você não tiver um token, gere um.
3. Recupere o `clientId` e `clientSecret` de um dos tokens gerados.

{% hint style="warning" %}
Não armazene esses campos diretamente no seu aplicativo móvel/web. Esses valores não devem sair do seu backend.
{% endhint %}

{% hint style="info" %}
Você pode repetir este procedimento para gerar acessos combinando diferentes funções e SDKs.
{% endhint %}

## **Gerando seu token**

### **Método recomendado**

As etapas a seguir descrevem como você pode gerar um token que é válido apenas para um usuário específico. Esta é a forma recomendada de gerar e distribuir tokens porque limita um possível ataque a uma única conta de usuário.

1. Em algum momento no fluxo do seu aplicativo, crie um JWT com a estrutura do exemplo abaixo;
   * Lembre-se de substituir os `{clientId}`, `{personId}` e `{expiresAt}` campos.
   * Todos esses campos são fortemente recomendados, mas você pode ver quais são obrigatórios no final desta página.
2. Assine o token com o seu `clientSecret`;
3. Envie este token para sua aplicação.

**Exemplo:**

{% tabs %}
{% tab title="Cabeçalho" %}

```json
{
  "alg": "HS256",
  "typ": "JWT"
}
```

{% endtab %}

{% tab title="Payload" %}

```json
{
    "iss": "{clientId}", // string
    "exp": {expiresAt}, // número
    "personId": "{personId}" // string
}
```

{% endtab %}
{% endtabs %}

### **Método não recomendado (somente para testes)**

1. Acesse [jwt.io](https://jwt.io/);
2. Mantenha o **Cabeçalho** campo, não altere;
3. Edite o payload, apenas o `iss` campo é obrigatório;
4. Substitua \*\*\*\* `your-256-bit-secret` pelo seu `clientSecret`;
5. Clique em **Share JWT** para copiar o token gerado para a área de transferência;
6. Use este token para autenticar o SDK.

### **Parâmetros do payload do JWT**

| Parâmetro      | Obrigatório | Descrição                                                                                   |
| -------------- | ----------- | ------------------------------------------------------------------------------------------- |
| **`iss`**      | Sim         | Seu `clientId`                                                                              |
| **`exp`**      | Não         | Tempo de expiração (em segundos desde a [Era Unix](https://pt.wikipedia.org/wiki/Era_Unix)) |
| **`personId`** | Não         | O ID da pessoa (identificador único do usuário) para o qual o token será válido             |


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.caf.io/caf-docs/caf-product-guides-pt-br/guia-do-usuario/smart-auth/access-token.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
