@@ -32,11 +32,16 @@ interface OauthWebLogin {
3232export class AuthManager {
3333 private client : Auth . OAuth2Client | null = null ;
3434 private scopes : string [ ] ;
35+ private onStatusUpdate : ( ( message : string ) => void ) | null = null ;
3536
3637 constructor ( scopes : string [ ] ) {
3738 this . scopes = scopes ;
3839 }
3940
41+ public setOnStatusUpdate ( callback : ( message : string ) => void ) {
42+ this . onStatusUpdate = callback ;
43+ }
44+
4045 private isTokenExpiringSoon ( credentials : Auth . Credentials ) : boolean {
4146 return ! ! ( credentials . expiry_date &&
4247 credentials . expiry_date < Date . now ( ) + TOKEN_EXPIRY_BUFFER_MS ) ;
@@ -156,16 +161,20 @@ export class AuthManager {
156161
157162 const webLogin = await this . authWithWeb ( oAuth2Client ) ;
158163 await open ( webLogin . authUrl ) ;
159- console . log ( 'Waiting for authentication...' ) ;
164+ const msg = 'Waiting for authentication... Check your browser.' ;
165+ logToFile ( msg ) ;
166+ if ( this . onStatusUpdate ) {
167+ this . onStatusUpdate ( msg ) ;
168+ }
160169
161170 // Add timeout to prevent infinite waiting when browser tab gets stuck
162171 const authTimeout = 5 * 60 * 1000 ; // 5 minutes timeout
163172 const timeoutPromise = new Promise < never > ( ( _ , reject ) => {
164173 setTimeout ( ( ) => {
165174 reject (
166175 new Error (
167- 'Authentication timed out after 5 minutes. The browser tab may have gotten stuck in a loading state . ' +
168- 'Please try again.' ,
176+ 'User is not authenticated. Authentication timed out after 5 minutes. The user did not complete the login process in the browser . ' +
177+ 'Please ask the user to check their browser and try again.' ,
169178 ) ,
170179 ) ;
171180 } , authTimeout ) ;
0 commit comments