@@ -125,7 +125,7 @@ abstract class TokenManager {
125125 /**
126126 * Generate state and verifier for PKCE
127127 */
128- const { authorizeUrlOptions } = generateAndStoreAuthUrlValues ( {
128+ const [ pkceValues , storePkceValues ] = generateAndStoreAuthUrlValues ( {
129129 ...config ,
130130 clientId,
131131 prefix,
@@ -138,7 +138,7 @@ abstract class TokenManager {
138138 try {
139139 // Check expected browser support
140140 // To support legacy browsers, iframe works best with short timeout
141- const parsedUrl = new URL ( await OAuth2Client . getAuthCodeByIframe ( authorizeUrlOptions ) ) ;
141+ const parsedUrl = new URL ( await OAuth2Client . getAuthCodeByIframe ( pkceValues ) ) ;
142142
143143 // Throw if we have an error param or have no authorization code
144144 if ( parsedUrl . searchParams . get ( 'error' ) ) {
@@ -180,16 +180,19 @@ abstract class TokenManager {
180180 throw err ;
181181 }
182182
183- const authorizeUrl = await OAuth2Client . createAuthorizeUrl ( authorizeUrlOptions ) ;
183+ const authorizeUrl = await OAuth2Client . createAuthorizeUrl ( pkceValues ) ;
184+
185+ // Before redirecting, store PKCE values
186+ storePkceValues ( ) ;
184187
185188 return location . assign ( authorizeUrl ) ;
186189 }
187190 /**
188191 * Exchange authorization code for tokens
189192 */
190193 return await this . tokenExchange ( options , {
191- state : authorizeUrlOptions . state ,
192- verifier : authorizeUrlOptions . verifier ,
194+ state : pkceValues . state ,
195+ verifier : pkceValues . verifier ,
193196 } ) ;
194197 }
195198
0 commit comments