Skip to content

Commit

Permalink
Add support custom params during token exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
dopsonbr committed Mar 12, 2021
1 parent 71264d1 commit 1df0392
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ export class CodeFlowCallbackHandlerService {

let headers: HttpHeaders = new HttpHeaders();
headers = headers.set('Content-Type', 'application/x-www-form-urlencoded');

const bodyForCodeFlow = this.urlService.createBodyForCodeFlowCodeRequest(callbackContext.code);
const bodyForCodeFlow = this.urlService.createBodyForCodeFlowCodeRequest(
callbackContext.code,
this.configurationProvider.openIDConfiguration?.customParams
);

return this.dataService.post(tokenEndpoint, bodyForCodeFlow, headers).pipe(
switchMap((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class UrlService {
return revocationEndpointUrl;
}

createBodyForCodeFlowCodeRequest(code: string): string {
createBodyForCodeFlowCodeRequest(code: string, customParams?: { [p: string]: string | number | boolean }): string {
const codeVerifier = this.flowsDataService.getCodeVerifier();
if (!codeVerifier) {
this.loggerService.logError(`CodeVerifier is not set `, codeVerifier);
Expand Down Expand Up @@ -182,6 +182,10 @@ export class UrlService {
if (!redirectUrl) {
return null;
}
if (customParams) {
const customParamText = this.composeCustomParams({ ...customParams });
return oneLineTrim`${dataForBody}${customParamText}&redirect_uri=${redirectUrl}`;
}

return oneLineTrim`${dataForBody}&redirect_uri=${redirectUrl}`;
}
Expand Down

0 comments on commit 1df0392

Please sign in to comment.