> 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/user-guide/smart-auth/access-token.md).

# Access Token

To use Smart Auth SDK, you will need to generate two access tokens: one for Smart Auth and another one for Face Liveness. This page shows the steps on how to create the keys, generate the access tokens and the recommended ways to do it.

## **Getting your Face Liveness keys**

Go to [SDK's access token tutorial page](https://docs.caf.io/caf-sdk/sdk_integration_documentation) to see how to generate it.

## **Getting your Smart Auth keys**

1. Go to the [Smart Auth tokens page](https://identity.combateafraude.com/tokens);
2. If you do not have a token, generate one.
3. Retrieve the `clientId` and `clientSecret` from one of the generated tokens.

{% hint style="warning" %}
Do not store these fields directly in your mobile/web application. These values should not leave your backend.
{% endhint %}

{% hint style="info" %}
You can repeat this procedure to generate accesses combining different functions and SDKs.
{% endhint %}

## **Generating your token**

### **Recommended method**

The following steps describe how you can generate a token that is valid only for a specific user. This is the recommended way to generate and distribute tokens because it limits a possible attack to a single user account.

1. At some point in your application flow, create a JWT with the structure of the example below;
   * Remember to replace the `{clientId}`, `{personId}` and `{expiresAt}` fields.
   * All of these fields are strongly recommended, but you can see which ones are required at the bottom of this page.
2. Sign the token with your `clientSecret`;
3. Send this token to your application.

**Example:**

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

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

{% endtab %}

{% tab title="Payload" %}

```json
{
    "iss": "{clientId}", // string
    "exp": {expiresAt}, // number
    "personId": "{personId}" // string
}
```

{% endtab %}
{% endtabs %}

### **Not recommended method (only for tests)**

1. Go to [jwt.io](https://jwt.io/);
2. Keep the **Header** field, do not change;
3. Edit the payload, only the `iss` field is required;
4. Replace \*\*\*\* `your-256-bit-secret` with your `clientSecret`;
5. Click **Share JWT** to copy the generated token to the clipboard;
6. Use this token to authenticate the SDK.

### **JWT payload parameters**

| Parameter      | Required | Description                                                                            |
| -------------- | -------- | -------------------------------------------------------------------------------------- |
| **`iss`**      | Yes      | Your `clientId`                                                                        |
| **`exp`**      | No       | Expiration time (seconds since the [Unix Era](https://pt.wikipedia.org/wiki/Era_Unix)) |
| **`personId`** | No       | The Person Id (Unique identifier for the user) for which the token will be valid       |


---

# 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.caf.io/caf-docs/user-guide/smart-auth/access-token.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.
