diff --git a/lib/access-token.js b/lib/access-token.js index 528371d..337d08c 100644 --- a/lib/access-token.js +++ b/lib/access-token.js @@ -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); } diff --git a/test/access-token-refresh.js b/test/access-token-refresh.js index bf4f7ef..aaa1360 100644 --- a/test/access-token-refresh.js +++ b/test/access-token-refresh.js @@ -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); });