File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,18 @@ export class Authenticator {
3737 } ) ;
3838
3939 try {
40+ this . accessToken = undefined ;
41+
4042 const { access_token } = await httpClient
4143 . request < {
4244 access_token : string ;
4345 } > ( "POST" , url , { body, retry : false } )
4446 . ready ( ) ;
4547 this . accessToken = access_token ;
4648 } catch ( error ) {
49+ console . log ( "Failed to refresh access token" ) ;
50+ console . error ( error ) ;
51+ console . log ( "Performing login..." ) ;
4752 await this . authenticate ( ) ;
4853 }
4954 }
@@ -61,6 +66,8 @@ export class Authenticator {
6166 password
6267 } ) ;
6368
69+ this . accessToken = undefined ;
70+
6471 const { access_token, refresh_token } = await httpClient
6572 . request < Login > ( "POST" , url , {
6673 body,
Original file line number Diff line number Diff line change @@ -52,14 +52,13 @@ export class NodeHttpClient {
5252
5353 const withProtocol = assignProtocol ( url ) ;
5454
55+ const userAgent = headers [ "user-agent" ] || DEFAULT_USER_AGENT ;
5556 const response = await fetch ( withProtocol , {
5657 agent,
5758 signal : controller . signal as AbortSignal ,
5859 method,
5960 headers : {
60- "user-agent" : headers [ "user-agent" ]
61- ? headers [ "user-agent" ]
62- : DEFAULT_USER_AGENT ,
61+ "user-agent" : userAgent ,
6362 "Content-Type" : "application/json" ,
6463 ...headers
6564 } ,
@@ -70,6 +69,7 @@ export class NodeHttpClient {
7069 try {
7170 await this . authenticator . refreshAccessToken ( ) ;
7271 } catch ( error ) {
72+ console . error ( error ) ;
7373 throw new AuthenticationError ( {
7474 message : "Failed to refresh access token"
7575 } ) ;
You can’t perform that action at this time.
0 commit comments