2

I am trying to authorize another sandbox/production to create connection. When I first time authorize the connected app, it is returning the Auhorization Code in the URL, however when it gets redirected to LWC app, code is disappeared because the parameter is 'code' not like 'c__code'. So, pagereference state is unable to read the param value. It was working till the previous release, with Spring release it started behaving differently.

Original URL: not working

https://xxxx.lightning.force.com/lightning/n/Deployment_Tool?code=aPrxmksMoIsrem319S_JL_ssM0may9ttdjsdP6MjyuRrJYxtMz9MphqoRf7eQj8tbm5Lgw.Tg%3D%3D

I tested with adding 'c__' to the param manually and it worked fine.

Modified URL: Working

https://xxxxx.lightning.force.com/lightning/n/Deployment_Tool?c__code=aPrxmksMoIsrem319S_ssM0may9ttdjsdP6MjyuRrJYxtMz9MphqoRf7eQj8tbm5Lgw.Tg%3D%3D

is there a way we can rename the redirected URL params dynamically?

'code' to 'c__code'

2
  • from where are you generating this URL? Please explain which two systems you are trying to integrate and how? Feb 29 '20 at 16:56
  • it is simple authorization between two salesforce sandboxes. using a connected app. Authorization URL: /services/oauth2/authorize?client_id='+this.clientid+'&redirect_uri=xxx--staging2.lightning.force.com/lightning/n/…
    – Ajay
    Feb 29 '20 at 18:28
4

The State parameter of the URL addressable component using pagereference always needs a namespace. For normal orgs c is the namespace and hence you will need to make sure within the URL parameter you pass the namespace.

A workaround for this is to first redirect it to a visualforce page which upon load can read parameter and redirect to a lightning URL with correct namespace i.e c__parametername and for an ISV app it will be namespace__parametername

The other approach would be to use VF page itself to do an OAuth dance and then post the message back to the lwc component (window.postmessage or use LMS) and close the vf page.

1
  • 1
    Yes, make sense. It uses to work before, with recent releases it is stopped working now. Maybe I will go with VF page approach
    – Ajay
    Jul 27 '20 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.