Skip to content

Commit

Permalink
Throw error if there is no refresh token despite the necessity of ref…
Browse files Browse the repository at this point in the history
…reshing (#605)

If OAuth2Client without refresh token has no access token or
has an expired access token, `OAuth2Client.prototype.getAccessToken`
throws "No refresh token is set." error.

This commit also reduces the number of unreachable code.
  • Loading branch information
yuku authored and JustinBeckwith committed Jan 27, 2019
1 parent e660246 commit a61dddf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/auth/oauth2client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ export class OAuth2Client extends AuthClient {
private async getAccessTokenAsync(): Promise<GetAccessTokenResponse> {
const shouldRefresh =
!this.credentials.access_token || this.isTokenExpiring();
if (shouldRefresh && this.credentials.refresh_token) {
if (shouldRefresh) {
if (!this.credentials.refresh_token) {
throw new Error('No refresh token is set.');
}
Expand Down

0 comments on commit a61dddf

Please sign in to comment.