> ## 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         | 以空格分隔的 scope 列表，表示你希望用户同意的权限。此列表应为你在 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 客户端界面示例：**

![示例 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 scope 授权绑定的授权码。此代码用于交换为包含用户已同意 `scopes` 的一等公民 `accessToken` 和 `refreshToken`。更多信息参见 [Exchange an OAuth Code](/exchange-an-o-auth-authorization-code)。 |
| state        | 与初始请求中传入的值相同，未被修改。                                                                                                                                                |

如果 URL 配置不正确，该 URL 的响应将包含描述错误的错误消息。
