Skip to content

Commit

Permalink
fix: keep old refreshToken
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Jan 7, 2025
1 parent bee1539 commit 8128710
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/access-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = class AccessToken {
const response = await this.#client.request(this.#config.auth.refreshPath, parameters.toObject(), httpOptions);

if (response[REFRESH_TOKEN_PROPERTY_NAME] === undefined) {
response.refresh_token = this.refresh_token;
response.refresh_token = this.token.refresh_token;
}
return new AccessToken(this.#config, this.#client, response);
}
Expand Down
2 changes: 2 additions & 0 deletions test/access-token-refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,10 @@ test.serial('@refresh => creates a new access token with keeping the old refresh
const scope = server.tokenSuccessWithoutRefreshToken(scopeOptions, refreshParams);

const accessToken = new AccessToken(config, client, accessTokenResponse);
const refreshToken = accessToken.token.refresh_token;
const refreshAccessToken = await accessToken.refresh();

scope.done();
t.true(has(refreshAccessToken.token, 'refresh_token'));
t.is(refreshAccessToken.token.refresh_token, refreshToken);
});

0 comments on commit 8128710

Please sign in to comment.