File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -169,22 +169,29 @@ export class TdeiClient extends BaseHttpClient implements ICancelableClient {
169169 }
170170
171171 async refreshToken ( ) {
172- const response = await super . _post ( 'refresh-token' , this . #auth. refreshToken ) ;
173-
174- if ( response . status === 401 ) {
175- this . #auth. clear ( ) ;
172+ try {
173+ const response = await super . _send ( 'refresh-token' , 'POST' , this . #auth. refreshToken ) ;
174+ this . #setAuth( this . #auth. username , await response . json ( ) ) ;
175+ } catch ( e : unknown ) {
176+ if ( e instanceof BaseHttpClientError && e . response . status === 401 ) {
177+ this . #auth. clear ( ) ;
178+ }
176179 }
177-
178- this . #setAuth( this . #auth. username , await response . json ( ) ) ;
179180 }
180181
181182 async tryRefreshAuth ( ) {
182- if ( this . #auth. needsRefresh ) {
183+ if ( ! this . #auth. needsRefresh ) {
184+ return false ;
185+ }
186+
187+ try {
183188 await this . refreshToken ( ) ;
184- return true
189+ } catch ( e : unknown ) {
190+ console . warn ( 'Exception when refreshing TDEI access token' , e ) ;
191+ return false ;
185192 }
186193
187- return false
194+ return true ;
188195 }
189196
190197 restartAutoAuthRefresh ( ) {
You can’t perform that action at this time.
0 commit comments