> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fluz.app/llms.txt
> Use this file to discover all available pages before exploring further.

# 面向用戶的 OAuth 授權流程

## 在 Fluz 中啟動 OAuth 流程

請確保你的 [OAuth](/configure-o-auth-app) 設定皆正確。

引導你的終端使用者前往 `https://uni.staging.fluzapp.com/authorize`

並附上以下查詢參數：

| query param    | description                                                                                  |
| :------------- | :------------------------------------------------------------------------------------------- |
| response\_type | 若要提出 OAuth 權限請求，該值應為 `code`。                                                                 |
| client\_id     | 來自 OAuth 設定的應用程式 OAuth client ID。                                                            |
| redirect\_uri  | 來自 OAuth 設定、在你的應用程式中設定的 redirect\_uri。                                                       |
| scopes         | 以空白分隔的 scopes 列表，代表你希望使用者同意的權限。此列表應為你在 OAuth 設定中已選取的 scopes 之子集合。若加入未為你的應用程式啟用的 scope，將會被忽略。 |
| state          | 可選欄位，可用於在\_你的用戶端\_持久化一些資訊，因為在成功的 OAuth 重新導向時會一併包含該值。                                         |

可用 scopes 的清單在此處： [Authentication](/concepts/authentication)

以下為預期格式的範例：

```text theme={null}
https://uni.staging.fluzapp.com/authorize?response_type=code&client_id=dab5c80e-0321-4c3a-988a-ffedfd64d8db&redirect_uri=https://google.com/oauth/finalize&scopes=MAKE_DEPOSIT%20LIST_PAYMENT%20MAKE_WITHDRAW%20REVEAL_VIRTUALCARD
```

**OAuth 用戶端 UI 範例：**

![範例 OAuth 權限頁面](https://storage.googleapis.com/fluz-fluz-file-uploads-staging-wlfprelricuyxowb/assets/oauth-widget-permissions.png)

## 預期回應

如果你正確組建 URL，且該 URL 與設定相符，系統會將用戶重新導向至你的 `redirect_uri`，並附上以下查詢參數：

| query params | description                                                                                                                                                                         |
| :----------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| code         | 綁定至該使用者 OAuth scopes 授權的 authorization code。此代碼用於交換成包含使用者已同意 `scopes` 的第一類 `accessToken` 與 `refreshToken`。更多資訊請參見 [Exchange an OAuth Code](/exchange-an-o-auth-authorization-code)。 |
| state        | 與你在初始請求中傳遞的值相同，且未被修改。                                                                                                                                                               |

若 URL 設定不正確，該 URL 的回應會包含描述錯誤的錯誤訊息。
