From 67f1a9fe443ec09749706cbf7ce2c8e5c4ef6a04 Mon Sep 17 00:00:00 2001 From: "jakub.vilhan" Date: Sun, 27 Oct 2024 23:03:35 +0100 Subject: [PATCH] Fix update getToken to support async token fetch --- src/callback-endpoint.ts | 2 +- src/types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/callback-endpoint.ts b/src/callback-endpoint.ts index e27c113..30205f0 100644 --- a/src/callback-endpoint.ts +++ b/src/callback-endpoint.ts @@ -45,7 +45,7 @@ export const createCallbackEndpoint = ( let access_token: string; if (pluginOptions.getToken) { - access_token = pluginOptions.getToken(code); + access_token = await pluginOptions.getToken(code); } else { const tokenResponse = await fetch(pluginOptions.tokenEndpoint, { method: "POST", diff --git a/src/types.ts b/src/types.ts index 1367a89..32c6cd4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -115,7 +115,7 @@ export interface PluginTypes { * Function to get token from the OAuth providers. * If its not provided default will be used. */ - getToken?: (code: string) => string; + getToken?: (code: string) => string | Promise; /** * Redirect users after successful login.