跳轉到主要內容

函式:createVerifyJwt()

function createVerifyJwt(getKey: JWTVerifyGetKey, options?: JWTVerifyOptions): VerifyAccessTokenFunction;

建立一個函式,使用提供的金鑰擷取函式與選項來驗證 JWT 存取權杖 (Access token)。

參數​

getKey​

JWTVerifyGetKey

用於擷取驗證 JWT 所需金鑰的函式。

參見

JWTVerifyGetKey 以取得金鑰擷取函式的型別定義。

options?​

JWTVerifyOptions

可選的 JWT 驗證選項。

參見

JWTVerifyOptions 以取得選項的型別定義。

回傳值​

VerifyAccessTokenFunction

一個用於驗證 JWT 存取權杖 (Access token) 的函式,若權杖有效則回傳 AuthInfo 物件。此函式要求 JWT 的 payload 中必須包含 iss、client_id 與 sub 欄位,且可選擇性包含 scope 或 scopes 欄位。該函式底層使用 jose 函式庫進行 JWT 驗證。

參見​

VerifyAccessTokenFunction 以取得回傳函式的型別定義。