> ## 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 存取權杖

您可以重新整理從授權 `code` 交換取得的 accessToken

若要重新整理存取權杖，請對 /token/refresh 發出請求，並附上以下查詢參數：

| 查詢參數           | 說明                      |
| -------------- | ----------------------- |
| refresh\_token | 來自授權權杖交換的 refreshToken。 |

另外，設定 Authorization 標頭為由您的 client\_id:app\_secret 組合後再以 base64 編碼的字串。這是 Basic 認證標頭，因此應符合以下格式：`Authorization: Basic <base64 encoded CLIENT_ID:CLIENT_SECRET>`

例如，若您的 `client_id` 是 `abc123`，而 OAuth 設定中的 `client_secret` 是 `def456`，則 base64 編碼的值會是 `YWJjMTIzOmRlZjQ1Ng==`。

`client_id` 與 `client_secret` 可在 [設定 OAuth 應用程式](/configure-o-auth-app) 的 `Overview` 分頁中找到。

以下是範例 cURL 指令：

```text theme={null}
curl -X GET "https://uni.staging.fluzapp.com/token/refresh?refresh_token=<refreshToken>" -H "Authorization: Basic YWJjMTIzOmRlZjQ1Ng=="
```

回應將包含：

| 查詢參數         | 說明                             |
| :----------- | :----------------------------- |
| accessToken  | 用於之後呼叫 Fluz 後端服務的短期權杖          |
| refreshToken | 當 accessToken 到期時要儲存並使用的重新整理權杖 |
| scopes       | 使用者在先前流程中授權的值                  |

以下是完整回應範例：

```json theme={null}
{"accessToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTc1MjA5NDgwNH0.0dKCtVpN0mTHHMuGNNx4VLJisTnovFNPQKhSw6zWosc","authorizationCode":"f082972eb110b80f73b0d0f95d1de9266069a1e4","accessTokenExpiresAt":"2025-07-08T21:05:30.673Z","refreshToken":"8ec16c25951616150b0332a4a6d66547","refreshTokenExpiresAt":"2025-08-08T20:55:30.738Z","scope":\["MAKE\_WIDTHDRAW","MAKE\_DEPOSIT","LIST\_PAYMENT"],"client":\{"id":"dab5c80e-0321-4c3a-988a-ffedfd64d8db","app\_id":"0a92d46e-edf4-422e-8c62-946051e5067b","app\_name":"First OAuth integration","grants":\["authorization\_code","client\_credentials","password","refresh\_token"],"redirectUris":\["http\://localhost:3035/oauth/finalize"],"accessTokenLifetime":600},"user":\{"id":"5070d5a1-d71a-4190-91b0-f116eec51771"}}
```
