From 84baba818b6d6e5562e9cf15a9b2cedb492beb64 Mon Sep 17 00:00:00 2001 From: Anthony Vito <4698802+anthony-vito@users.noreply.github.com> Date: Tue, 12 Dec 2023 01:57:02 -0500 Subject: [PATCH] fix: The token request should not include the scope parameter (#130) --- src/Types.ts | 2 +- src/authentication.ts | 1 - tests/get_token.test.tsx | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Types.ts b/src/Types.ts index 6f1d1fd..fa2b871 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -2,7 +2,6 @@ import { ReactNode } from 'react' interface TTokenRqBase { grant_type: string - scope?: string client_id: string redirect_uri: string } @@ -13,6 +12,7 @@ export interface TTokenRequestWithCodeAndVerifier extends TTokenRqBase { } export interface TTokenRequestForRefresh extends TTokenRqBase { + scope?: string refresh_token: string } diff --git a/src/authentication.ts b/src/authentication.ts index 4364344..d542960 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -81,7 +81,6 @@ export const fetchTokens = (config: TInternalConfig): Promise => const tokenRequest: TTokenRequestWithCodeAndVerifier = { grant_type: 'authorization_code', code: authCode, - scope: config.scope, client_id: config.clientId, redirect_uri: config.redirectUri, code_verifier: codeVerifier, diff --git a/tests/get_token.test.tsx b/tests/get_token.test.tsx index 5828f8e..17b5137 100644 --- a/tests/get_token.test.tsx +++ b/tests/get_token.test.tsx @@ -33,7 +33,7 @@ test('make token request with extra parameters', async () => { await waitFor(() => expect(fetch).toHaveBeenCalledWith('myTokenEndpoint', { - body: 'grant_type=authorization_code&code=1234&scope=someScope%20openid&client_id=anotherClientId&redirect_uri=http%3A%2F%2Flocalhost%2F&code_verifier=arandomstring&testTokenKey=tokenValue', + body: 'grant_type=authorization_code&code=1234&client_id=anotherClientId&redirect_uri=http%3A%2F%2Flocalhost%2F&code_verifier=arandomstring&testTokenKey=tokenValue', headers: { 'Content-Type': 'application/x-www-form-urlencoded', },