File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -55,21 +55,21 @@ export class ApiClient {
55
55
return this . accessToken ?. token . access_token as string | undefined ;
56
56
} ;
57
57
58
- private authMiddleware = ( apiClient : ApiClient ) : Middleware => ( {
59
- async onRequest ( { request, schemaPath } ) {
58
+ private authMiddleware : Middleware = {
59
+ onRequest : async ( { request, schemaPath } ) => {
60
60
if ( schemaPath . startsWith ( "/api/private/unauth" ) || schemaPath . startsWith ( "/api/oauth" ) ) {
61
61
return undefined ;
62
62
}
63
63
64
64
try {
65
- const accessToken = await apiClient . getAccessToken ( ) ;
65
+ const accessToken = await this . getAccessToken ( ) ;
66
66
request . headers . set ( "Authorization" , `Bearer ${ accessToken } ` ) ;
67
67
return request ;
68
68
} catch {
69
69
// ignore not availble tokens, API will return 401
70
70
}
71
71
} ,
72
- } ) ;
72
+ } ;
73
73
74
74
private readonly errorMiddleware : Middleware = {
75
75
async onResponse ( { response } ) {
@@ -108,7 +108,7 @@ export class ApiClient {
108
108
tokenPath : "/api/oauth/token" ,
109
109
} ,
110
110
} ) ;
111
- this . client . use ( this . authMiddleware ( this ) ) ;
111
+ this . client . use ( this . authMiddleware ) ;
112
112
}
113
113
this . client . use ( this . errorMiddleware ) ;
114
114
}
You can’t perform that action at this time.
0 commit comments