Skip to content

Commit b3cbc70

Browse files
Always use refreshAccessTokenIfNeeded to refresh access token
ref DEV-3054
2 parents 117e3aa + 89ca7b5 commit b3cbc70

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

packages/authgear-core/src/client.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,7 @@ export class _BaseAPIClient {
103103
throw new AuthgearError("missing delegate in api client");
104104
}
105105

106-
const shouldRefresh = this._delegate.shouldRefreshAccessToken();
107-
if (shouldRefresh) {
108-
await this._delegate.refreshAccessToken();
109-
}
106+
await this._delegate.refreshAccessTokenIfNeeded();
110107

111108
const request = new this._Request(input, init);
112109

packages/authgear-core/src/types.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,10 @@ export interface _APIClientDelegate {
151151
*/
152152
getAccessToken(): string | undefined;
153153

154-
/**
155-
* Called by the API Client before sending HTTP request.
156-
* If true is returned, refreshAccessToken() is then called.
157-
*/
158-
shouldRefreshAccessToken(): boolean;
159-
160154
/**
161155
* Called by the API client to refresh the access token.
162156
*/
163-
refreshAccessToken(): Promise<void>;
157+
refreshAccessTokenIfNeeded(): Promise<void>;
164158
}
165159

166160
/**

0 commit comments

Comments
 (0)