Skip to content

Commit

Permalink
feat: if token expires soon, force refresh (#794)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored and callmehiphop committed Sep 27, 2019
1 parent 8640028 commit fecd4f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"fast-text-encoding": "^1.0.0",
"gaxios": "^2.0.0",
"gcp-metadata": "^3.0.0",
"gtoken": "^4.0.0",
"gtoken": "^4.1.0",
"jws": "^3.1.5",
"lru-cache": "^5.0.0"
},
Expand Down
4 changes: 3 additions & 1 deletion src/auth/jwtclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export class JWT extends OAuth2Client {
refreshToken?: string | null
): Promise<GetTokenResponse> {
const gtoken = this.createGToken();
const token = await gtoken.getToken();
const token = await gtoken.getToken({
forceRefresh: this.isTokenExpiring(),
});
const tokens = {
access_token: token.access_token,
token_type: 'Bearer',
Expand Down

0 comments on commit fecd4f4

Please sign in to comment.