> For the complete documentation index, see [llms.txt](https://api-docs.aicall.vbee.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-docs.aicall.vbee.ai/huong-dan-khoi-tao/huong-dan-tao-access-token.md).

# Hướng dẫn tạo access token

Access Token là một chuỗi ký tự cho phép dịch vụ của bạn có thể sử dụng AICall APIs.

#### Dưới đây là các bước tạo ACCESS\_TOKEN

1. Lấy thông tin **API\_KEY**, **API\_SECRET** từ ứng dụng đã tạo

<figure><img src="https://2923050889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRQqKJQTeB1Hu2hxPxLlu%2Fuploads%2F9XsQUaEsSZbyKPq9cpvY%2Fimage.png?alt=media&amp;token=d2294a63-cc5d-4301-90a0-ce97d7f0c21e" alt=""><figcaption><p>Màn hình Giao diện thông tin ứng dụng</p></figcaption></figure>

2. Tạo **ACCESS\_TOKEN**

Bạn cần tạo Access Token bằng thực thi các câu lệnh, dưới đây là các câu lệnh mẫu theo các ngôn ngữ:

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

```javascript
const jwt = require('jsonwebtoken');

const API_KEY = '<API_KEY>';
const API_SECRET = '<API_SECRET>';

const ACCESS_TOKEN = jwt.sign({ apiKey: API_KEY }, API_SECRET);
```

{% endtab %}

{% tab title="Python" %}

```python
import jwt

API_KEY = '<API_KEY>'
API_SECRET = '<API_SECRET>'

ACCESS_TOKEN = jwt.encode({ apiKey: API_KEY }, API_SECRET)
```

{% endtab %}

{% tab title="Java" %}

```java
package org.example;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import java.util.Date;

public class Main {
   public static void main(String[] args) {
       String API_KEY = "<API_KEY>";
       String API_SECRET = "<API_SECRET>";
       
       Algorithm algorithm = Algorithm.HMAC256(API_SECRET);
       // Include the "iat" claim with the current timestamp
       long currentTimeMillis = System.currentTimeMillis();
       
       String ACCESS_TOKEN = JWT.create()
               .withClaim("apiKey", API_KEY)
               .withIssuedAt(new Date(currentTimeMillis)) // Include "iat" claim
               .sign(algorithm);
   }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
use \Firebase\JWT\JWT;
$API_KEY = '<API_KEY>';
$API_SECRET = '<API_SECRET>';

$ACCESS_TOKEN = JWT::encode([ "apiKey" => $API_KEY ], $API_SECRET, 'HS256');

```

{% endtab %}
{% endtabs %}

Sau khi thực thi code mẫu trên bạn nhận về **ACCESS\_TOKEN**
