Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
fix: add scope to refresh tokens
Browse files Browse the repository at this point in the history
adds scope to `exchangeRefreshToken`

fixes authts#364
  • Loading branch information
kasperp committed Feb 3, 2022
1 parent b7e885f commit 62bc823
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/OidcClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,9 @@ describe("OidcClient", () => {
const tokenResponse = {
access_token: "new_access_token",
};
jest.spyOn(subject["_tokenClient"], "exchangeRefreshToken").mockResolvedValue(tokenResponse);
const exchangeRefreshTokenMock =
jest.spyOn(subject["_tokenClient"], "exchangeRefreshToken")
.mockResolvedValue(tokenResponse);
jest.spyOn(JwtUtils, "decode").mockReturnValue({ sub: "sub" });
const state = new RefreshState({
refresh_token: "refresh_token",
Expand All @@ -371,6 +373,10 @@ describe("OidcClient", () => {
const response = await subject.useRefreshToken({ state });

// assert
expect(exchangeRefreshTokenMock).toHaveBeenCalledWith( {
refresh_token: "refresh_token",
scope: "openid",
});
expect(response).toBeInstanceOf(SigninResponse);
expect(response).toMatchObject(tokenResponse);
expect(response).toHaveProperty("scope", state.scope);
Expand Down
1 change: 1 addition & 0 deletions src/OidcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export class OidcClient {

const result = await this._tokenClient.exchangeRefreshToken({
refresh_token: state.refresh_token,
scope: state.scope,
timeoutInSeconds,
});
const response = new SigninResponse(new URLSearchParams());
Expand Down
1 change: 1 addition & 0 deletions src/TokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface ExchangeRefreshTokenArgs {

grant_type?: string;
refresh_token: string;
scope?: string;

timeoutInSeconds?: number;
}
Expand Down

0 comments on commit 62bc823

Please sign in to comment.