Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keep old refreshToken #456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
Loading