0

I am trying to understand authorization code flow using salesforce connected apps.

I have two different Salesforce orgs

I have created a connected app in one Salesforce org which has the following callback URL : https://fruitkiwi--fullcopysb.sandbox.my.salesforce.com/services/authcallback/Fruit_B2B

I have the above url because I was actually connecting another Salesforce org to this org using this connected app and updated the callback url with the url generated in the Auth Provider of the second Salesforce org. The integration between the two orgs is working correctly.

Now, I was trying to test authorization code flow using the same connected app and hit the following url from the browser:

https://login.salesforce.com/services/oauth2/authorize?client_id=3MVG9t0sl2P.pBypNCC99ogtGvVDRUX83MS3deq0i0VQOSaD6_EAZR5n_ZjooibitBpPDlBR7M88IVuu3tuq.&state=redirect_uri=https://fruitkiwi--fullcopysb.sandbox.my.salesforce.com/services/authcallback/Fruit_B2B&redirect_uri=https://fruitkiwi--fullcopysb.sandbox.my.salesforce.com/services/authcallback/Fruit_B2B&response_type=code&scope=full

But, I am getting the following error message

enter image description here

Now, if the change the callback url in the connected app to something like the following then the authorization code generation from the browser is working correctly.

https://login.salesforce.com/services/oauth2/success

Now, the request that I am hitting from the browser is

https://login.salesforce.com/services/oauth2/authorize?client_id=3MVG9t0sl2P.pBypNCC99ogtGvVDRUX83MS3deq0i0VQOSaD6_EAZR5n_ZjooibitBpPDlBR7M88IVuu3tuq.&state=redirect_uri=https://login.salesforce.com/services/oauth2/success&redirect_uri=https://login.salesforce.com/services/oauth2/success&response_type=code&scope=full

I was trying to understand why it is working with the below URL and not with the one above?

3
  • Your built URL is not even URL-encoded, start with that. Why are you trying to "build the URL"? Please edit the question and explain what you're trying to achieve in functional/UX terms.
    – identigral
    Commented Dec 5, 2022 at 21:19
  • I meant I am just hitting the url from the web browser. With the last callback url - login.salesforce.com/services/oauth2/success it is working perfectly, when I hit the url from the browser and I am getting the authentication code. I didn't have to encode the url at all.
    – Madhurima
    Commented Dec 5, 2022 at 21:42
  • The sequence of calls and requests/responses matter. In some cases you can pick a URL from the sequence and use it as a kind-of bookmark ("hitting from the web browser") but not in this case. Please edit the question and provide more information on your goals.
    – identigral
    Commented Dec 5, 2022 at 22:29

0

You must log in to answer this question.