驗證方式
此內容適用於 5.0 (Preview)。 切換至 4.5(目前版本) 以查看目前正式版文件。
所有發送至 QUEUE 後端服務的請求,都必須在 HTTP Header 中帶入 access_token。
cURL 請求範例
Section titled “cURL 請求範例”curl --location -g --request GET 'https://reporting.qpos.me/cubejs-api/v1/load?query={QUERY}' \--header 'Authorization: Bearer {access_token}'NodeJS Axios 請求範例
Section titled “NodeJS Axios 請求範例”var axios = require("axios");
var config = { method: "get", url: "https://reporting.qpos.me/cubejs-api/v1/load?query={QUERY}", headers: { Authorization: "Bearer {access_token}", },};
axios(config) .then(function (response) { console.log(JSON.stringify(response.data)); }) .catch(function (error) { console.log(error); });取得 Access Token
Section titled “取得 Access Token”https://capi.qpos.me/login請求參數(皆為必填)
Section titled “請求參數(皆為必填)”| 欄位 | 說明 |
|---|---|
| 電子郵件 | |
| password | 密碼 |
curl --request POST 'https://capi.qpos.me/login' \--header 'Content-Type: application/x-www-form-urlencoded' \--data-urlencode 'email=user@mail.com' \--data-urlencode 'password=secret_password'{ "access_token": "eyJhbGciOiJSU...", "refresh_token": "AFxQ4_pd...", "expires_in": 3600}使用 Refresh Token 換發 Access Token
Section titled “使用 Refresh Token 換發 Access Token”https://capi.qpos.me/refresh當 Access Token 即將過期或已過期時,可使用 Refresh Token 換取新的 Access Token。若 Refresh Token 已失效或被撤銷,使用者必須重新登入以取得新的權杖組。
請求參數(皆為必填)
Section titled “請求參數(皆為必填)”| 欄位 | 說明 |
|---|---|
| refresh_token | 登入時取得的 Refresh Token |
curl --request POST 'https://capi.qpos.me/refresh' \--header 'Content-Type: application/x-www-form-urlencoded' \--data-urlencode 'refresh_token=AFxQ4_r8BapvEWi81RJ...'{ "access_token": "eyJhbGciOiJSU...", "refresh_token": "AFxQ4_pd...", "expires_in": 3600}