Skip to content

Commit 0a02946

Browse files
fix: throw on missing refresh token in all cases (#670)
1 parent 8cc5522 commit 0a02946

File tree

2 files changed

+1027
-991
lines changed

2 files changed

+1027
-991
lines changed

src/auth/oauth2client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,9 @@ export class OAuth2Client extends AuthClient {
565565

566566
protected async refreshTokenNoCache(refreshToken?: string|
567567
null): Promise<GetTokenResponse> {
568+
if (!refreshToken) {
569+
throw new Error('No refresh token is set.');
570+
}
568571
const url = OAuth2Client.GOOGLE_OAUTH2_TOKEN_URL_;
569572
const data = {
570573
refresh_token: refreshToken,
@@ -612,9 +615,6 @@ export class OAuth2Client extends AuthClient {
612615
}
613616

614617
private async refreshAccessTokenAsync() {
615-
if (!this.credentials.refresh_token) {
616-
throw new Error('No refresh token is set.');
617-
}
618618
const r = await this.refreshToken(this.credentials.refresh_token);
619619
const tokens = r.tokens as Credentials;
620620
tokens.refresh_token = this.credentials.refresh_token;

0 commit comments

Comments
 (0)