Xero authentication - cannot pass custom URL parameter to backend

Viewed 30

I have a react application and node express backend API. I need to authenticate users for Xero. I'm using Xero node sdk (xero-node).

However I want to identify the user from the backend when Xero callback url is called.

I want to pass param1 as a custom parameter .

My approach

generating consent url and append a custom parameter.

 const xero = new XeroClient({
    clientId: `..`,
    clientSecret: `..`,
    redirectUris: ['/callback'],
    scopes: 'openid email profile '.split(" "),
  });
  
  return xero.buildConsentUrl()+`&param1=test`;

And I want to catch param1 in call back request.

In express callback function

  console.log('url ',req.url); 

Unfortunately param1 doesn't exists on callback request. I thought about using state parameter, however it's preserved for OpenID related stuff. So is there any way to pass something to Xero auth url.

0 Answers
Related