> For the complete documentation index, see [llms.txt](https://docs.rememberizer.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rememberizer.ai/zh-cn/kai-fa-zhe-zi-yuan/integration-options/authorizing-rememberizer-apps.md).

# 授权 Rememberizer 应用

Rememberizer 的实现支持标准的 [授权码授权类型](https://tools.ietf.org/html/rfc6749#section-4.1)。

授权用户使用您的应用的网络应用流程如下：

1. 用户被重定向到 Rememberizer 以授权他们的账户。
2. 用户选择要与您的应用一起使用的纪念品。
3. 您的应用使用用户的访问令牌访问 API。

访问 [管理第三方应用](/zh-cn/ge-ren-shi-yong/integrations/manage-third-party-apps.md#explore-third-party-apps-and-service) 页面以查看该流程的 UI 示例。

即将推出：OAuth2 授权流程图

该序列图将展示以下各方之间完整的 OAuth2 流程：

* 用户的浏览器
* 您的应用（客户端）
* Rememberizer 授权服务器
* Rememberizer API 资源

该图将展示在流程的所有步骤中授权码、令牌和 API 请求的交换。

### 步骤 1. 请求用户的 Rememberizer 身份

将用户重定向到 Rememberizer 授权服务器以启动身份验证和授权过程。

```
GET https://api.rememberizer.ai/api/v1/auth/oauth2/authorize/
```

参数：

<table><thead><tr><th width="236">名称</th><th>描述</th></tr></thead><tbody><tr><td>client_id</td><td><strong>必填</strong><br>您应用程序的客户端 ID。您可以在开发者中找到此值。点击左上角的 <strong>开发者</strong>。在注册应用程序列表中，点击您的应用程序，您将在 <strong>应用凭据</strong> 中看到客户端 ID。</td></tr><tr><td>response_type</td><td><strong>必填</strong><br>必须为 <code>code</code> 以获取授权码。</td></tr><tr><td>scope</td><td><p><strong>可选</strong></p><p>一个以空格分隔的作用域列表，标识您的应用程序可以代表用户访问的资源。</p></td></tr><tr><td>redirect_uri</td><td><strong>必填</strong><br>用户授权后将被发送到您应用程序中的 URL。</td></tr><tr><td>state</td><td><p><strong>必填</strong></p><p>客户端用于在请求和回调之间保持状态的一个不透明值。授权服务器在将用户代理重定向回客户端时包含此值。<br></p></td></tr></tbody></table>

### 步骤 2. 用户选择并配置他们的纪念品

用户将选择与您的应用一起使用的纪念品。

### 第 3 步。用户通过 Rememberizer 被重定向回您的网站

在用户选择他们的纪念品后，Rememberizer 会将用户重定向回您的网站，并带有一个临时的 `code` 参数以及您在上一步中提供的 `state` 参数。临时代码将在短时间后过期。如果状态不匹配，则请求是由第三方创建的，您应该中止该过程。

### 第 4 步. 交换授权码以获取刷新和访问令牌

```
POST https://api.rememberizer.ai/api/v1/auth/oauth2/token/
```

此端点接受以下输入参数。

<table><thead><tr><th width="165">名称</th><th>描述</th></tr></thead><tbody><tr><td>client_id</td><td><strong>必填</strong><br>您应用程序的客户端 ID。您可以在开发者中找到此值。查找此 ID 的说明在第 1 步中。</td></tr><tr><td>client_secret</td><td><strong>必填</strong><br>您从 Rememberizer 收到的应用程序客户端密钥。</td></tr><tr><td>code</td><td>您在第 3 步中收到的授权码。</td></tr><tr><td>redirect_uri</td><td><strong>必填</strong><br>用户在授权后被发送到您应用程序中的 URL。必须与第 1 步中的 redirect_uri 匹配。</td></tr></tbody></table>

### 第 5 步. 使用访问令牌访问 API

访问令牌允许您代表用户向 API 发出请求。

```
Authorization: Bearer OAUTH-TOKEN
GET https://api.rememberizer.ai/api/me/
```

例如，在 curl 中，您可以这样设置 Authorization 头：

```shell
curl -H "Authorization: Bearer OAUTH-TOKEN" https://api.rememberizer.ai/api/me/
```

## 参考资料

Github: <https://github.com/skydeckai/rememberizer-integration-samples>


---

# 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.rememberizer.ai/zh-cn/kai-fa-zhe-zi-yuan/integration-options/authorizing-rememberizer-apps.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.
