Skip to content

Commit

Permalink
Merge pull request #238 from nipunsampath/fix-redirect-url-in-access-…
Browse files Browse the repository at this point in the history
…token-request
  • Loading branch information
nipunsampath authored Nov 2, 2023
2 parents 7c67459 + 5f15768 commit 36c47f0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/src/core/authentication-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,27 +165,27 @@ export class AuthenticationCore<T> {
sessionState && (await this._dataLayer.setSessionDataParameter(
SESSION_STATE as keyof SessionData, sessionState, userID));

const body: string[] = [];
const body: URLSearchParams = new URLSearchParams();

body.push(`client_id=${ configData.clientID }`);
body.set("client_id", configData.clientID);

if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
body.push(`client_secret=${ configData.clientSecret }`);
body.set("client_secret", configData.clientSecret);
}

const code: string = authorizationCode;

body.push(`code=${ code }`);
body.set("code", code);

body.push("grant_type=authorization_code");
body.push(`redirect_uri=${ configData.signInRedirectURL }`);
body.set("grant_type", "authorization_code");
body.set("redirect_uri", configData.signInRedirectURL);

if (configData.enablePKCE) {
body.push(
`code_verifier=${ await this._dataLayer.getTemporaryDataParameter(
body.set(
"code_verifier", `${await this._dataLayer.getTemporaryDataParameter(
AuthenticationUtils.extractPKCEKeyFromStateParam(state),
userID
) }`
)}`
);

await this._dataLayer.removeTemporaryDataParameter(
Expand All @@ -198,7 +198,7 @@ export class AuthenticationCore<T> {

try {
tokenResponse = await fetch(tokenEndpoint, {
body: body.join("&"),
body: body,
credentials: configData.sendCookiesInRequests
? FetchCredentialTypes.Include
: FetchCredentialTypes.SameOrigin,
Expand Down

0 comments on commit 36c47f0

Please sign in to comment.