File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -42,10 +42,13 @@ export const createCallbackEndpoint = (
4242 // obtain access token
4343 // /////////////////////////////////////
4444
45- let tokenData ;
45+ let access_token : string ;
4646
4747 if ( pluginOptions . getToken ) {
48- tokenData = await pluginOptions . getToken ( code ) ;
48+ access_token = pluginOptions . getToken ( code ) ;
49+
50+ if ( typeof access_token !== "string" )
51+ throw new Error ( `No access token: ${ access_token } ` ) ;
4952 } else {
5053 const tokenResponse = await fetch ( pluginOptions . tokenEndpoint , {
5154 method : "POST" ,
@@ -61,12 +64,13 @@ export const createCallbackEndpoint = (
6164 grant_type : "authorization_code" ,
6265 } ) . toString ( ) ,
6366 } ) ;
64- tokenData = await tokenResponse . json ( ) ;
65- }
67+ const tokenData = await tokenResponse . json ( ) ;
6668
67- const access_token = tokenData ?. access_token ;
68- if ( typeof access_token !== "string" )
69- throw new Error ( `No access token: ${ JSON . stringify ( tokenData ) } ` ) ;
69+ access_token = tokenData ?. access_token ;
70+
71+ if ( typeof access_token !== "string" )
72+ throw new Error ( `No access token: ${ JSON . stringify ( tokenData ) } ` ) ;
73+ }
7074
7175 // /////////////////////////////////////
7276 // get user info
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ export interface PluginTypes {
115115 * Function to get token from the OAuth providers.
116116 * If its not provided default will be used.
117117 */
118- getToken ?: ( code : string ) => Promise < any > | any ;
118+ getToken ?: ( code : string ) => string ;
119119
120120 /**
121121 * Redirect users after successful login.
You can’t perform that action at this time.
0 commit comments