Skip to content

Commit

Permalink
add private client, mark code_challenge as not required in raml
Browse files Browse the repository at this point in the history
  • Loading branch information
yunakim714 committed Sep 12, 2024
1 parent bbfc077 commit 9189eb0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apis/shopper-login/shopper-login.raml
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ types:
The `code_challenge` is created by SHA256 hashing the `code_verifier` and Base64 encoding the resulting hash.
The `code_verifier` should be a high entropy cryptographically random string with a minimum of 43 characters and a maximum of 128 characters.
required: true
required: false
type: string
minLength: 43
maxLength: 128
Expand Down
18 changes: 18 additions & 0 deletions src/static/helpers/slasHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ export async function loginIDPUser(
clientId: string;
siteId: string;
}>,
credentials: {
clientSecret?: string;
},
parameters: {
redirectURI: string;
hint: string;
Expand All @@ -405,6 +408,21 @@ export async function loginIDPUser(
...(parameters.dnt !== undefined && {dnt: parameters.dnt.toString()}),
};

// Using private client
if (credentials.clientSecret) {
const authHeaderIdSecret = `Basic ${stringToBase64(
`${slasClient.clientConfig.parameters.clientId}:${credentials.clientSecret}`
)}`;

const optionsToken = {
headers: {
Authorization: authHeaderIdSecret,
},
body: tokenBody,
};
return slasClient.getAccessToken(optionsToken);
}

return slasClient.getAccessToken({body: tokenBody});
}

Expand Down

0 comments on commit 9189eb0

Please sign in to comment.