> For the complete documentation index, see [llms.txt](https://docs.coda.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/payout/ru-men-zhi-nan/ru-he-sheng-cheng-jwt-token.md).

# 如何生成 JWT Token

*有关 JWT  令牌的更多详细信息，请参阅*[*此处*](https://jwt.io/)*。*

JWT（或 JSON Web Token）是一种可以从您的payload生成的token，它提供了一种简单的方式来安全地在各方之间传输信息。

您可以使用 jwt 库 <https://jwt.io/libraries> 生成。然后，传递一个包含数据编码信息的header value，以及包含您的数据的payload。

Token header 应包含以下信息：

* alg：这是使用的signing algorithm。您向 Coda 发出的请求，请始终使用 **HS256**。
* typ：这是您要生成的token类型。您向 Coda 发出的请求，请始终使用“**JWT**”。

Token payload 应包含以下信息：

* partner\_id：这是 Coda 提供给您的合作伙伴 ID
* iat：token创建时间（UTC 时区）

请注意，生成的Token**有效期为 5 分钟。**

*注意：这是用于生成授权的Token header，而不是您向 Coda 发出请求的 header。请勿在向 Coda 发出的请求header中暴露 partnerId。*

## 示例

### Header: Algorithm and Secret

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

### **JWT token: Payload: data**

```javascript
{
  "partner_id": "1234567890",
  "iat": 1512203223
}
```

Payload也用于生成 JWT tokens。

要生成 JWT，您可以首先对token header和payload进行编码，然后使用您的Client Secret生成signature并将它们组合起来：

```javascript
key = '*yourclientsecret*'

unsignedToken = *encodeBase64Url(header) + '.' + encodeBase64Url(payload)*

signature = *HMAC-SHA256(key, unsignedToken)*

JWT = *unsignedToken + ‘.’ + signature*
```


---

# 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.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/payout/ru-men-zhi-nan/ru-he-sheng-cheng-jwt-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.
