# 授權 Rememberizer 應用程式

Rememberizer 的實作支援標準的 [授權碼授權類型](https://tools.ietf.org/html/rfc6749#section-4.1)。

授權用戶使用您的應用程式的網頁應用程式流程如下：

1. 用戶被重定向到 Rememberizer 以授權其帳戶。
2. 用戶選擇要與您的應用程式一起使用的紀念品。
3. 您的應用程式使用用戶的訪問令牌訪問 API。

訪問 [管理第三方應用程式](/zh-hk/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: 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:

```
GET https://docs.rememberizer.ai/zh-hk/kai-fa-zhe-zi-yuan/integration-options/authorizing-rememberizer-apps.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
