How to include additional parameters in the authorization URL

Options

Hello all,

I am trying to include additional parameters in my authorization URL and then access them in my backend lambda function. Below is what I have


const clientId = 'eb417d75-cf9d-4b91-9c78-707b396d7ff7';
const redirectUri = 'https://xxxxxx.com/dev/redirect_uri';
const scopes = 'core::'; /

// Additional parameters if needed
const additionalParams = {
param1: 'value1',
param2: 'value2',
};

// Construct the query string manually to avoid incorrect encoding
const queryParams = new URLSearchParams({
response_type: 'code',
client_id: clientId,
redirect_uri: redirectUri,
scope: scopes,
...additionalParams,
}).toString();


1. const d2lAuthorizationUrl = https://auth.brightspace.com/oauth2/auth?${queryParams};


2. const d2lAuthorizationUrl = https://auth.brightspace.com/oauth2/auth?response_type=code&client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(scopes)}&param1=value1&param2=value2;

window.location.href = d2lAuthorizationUrl;

In both the scenarios I am able to get the authorization code but not the additional params(undefined)

const authorizationCode = event.queryStringParameters.code; const param1 = queryStringParameters.param1;
const param2 = queryStringParameters.param2;

Is it possible to send additional parameters along with my authorizationUrl ?? If yes please guide me here.

Thanks

Aravind

Tagged: