Skip to content

Commit

Permalink
fix: throw on missing refresh token in all cases (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Apr 16, 2019
1 parent 8cc5522 commit 0a02946
Show file tree
Hide file tree
Showing 2 changed files with 1,027 additions and 991 deletions.
6 changes: 3 additions & 3 deletions src/auth/oauth2client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ export class OAuth2Client extends AuthClient {

protected async refreshTokenNoCache(refreshToken?: string|
null): Promise<GetTokenResponse> {
if (!refreshToken) {
throw new Error('No refresh token is set.');
}
const url = OAuth2Client.GOOGLE_OAUTH2_TOKEN_URL_;
const data = {
refresh_token: refreshToken,
Expand Down Expand Up @@ -612,9 +615,6 @@ export class OAuth2Client extends AuthClient {
}

private async refreshAccessTokenAsync() {
if (!this.credentials.refresh_token) {
throw new Error('No refresh token is set.');
}
const r = await this.refreshToken(this.credentials.refresh_token);
const tokens = r.tokens as Credentials;
tokens.refresh_token = this.credentials.refresh_token;
Expand Down
Loading

0 comments on commit 0a02946

Please sign in to comment.