+ Start a Discussion
netspidernetspider 

Having difficulty setting up oauth

I have 3 Salesforce orgs and I want 1 org to be able to access data in another org
Lets call the orgs
Client1 - the calling org
Client2 - the calling org
Dest1 - the destination org

So in Dest1 I have set up a connected App, no problem, which has a consumer key and a Consumer secret. For the Start URL I just created a quick visualforce page. I guess when the user connects from  Client1  and Client2 orgs they are shown this page.
I then go to the Client1  and Client2 orgs and create a Auth. Provider and I pasted the Consumer Key and Consumer Secret. All the other fields I left blank. Salesforce created a bunch of URLs in the Auth. Provider , 1 was "Existing User Linking URL". So I copied this url that Salesforce created into the browser thinking that this would open up my Start URL vf page and I will now have access to Dest1 org, but instead I got


error=redirect_uri_mismatch&error_description=redirect_uri%20must%20match%20configuration

So something is going wrong
Please help
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Hi netspider,

Please go through below link.

http://ashishsharmadevsfdc.blogspot.ae/2014/08/a-quick-salesforce-oauth-20-usage.html

Let us know if it helps you.
netspidernetspider
Hi Ashish 
It has helped a bit. I had done most of these things 
I will be using 
1. Authentication: Users are authenticated to what they say they are.(Through Client Idand Client Secret  )

However in the article Im not 100% sure what is the "Client Id"

It also says :
'Callback URl' , paste 'https://c.ap1.visual.force.com/apex/aouthWebServerFlow' which is a bit strange because the aouthWebServerFlow page is created in the Client but this setting is made in the DevOrg2 so to set https://c.ap1 surely this wont work if your instance is not ap1

Not sure if you can answer these questions

Thanks a lot in advance
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Hi netspider,

Follow these steps .
1. Create two salesforce DEV orgs eg. DEV 1 ,DEV 2.
2. In DEV 2 org ,create one connected app. Go to setup -> create -> new Connected App.(In this steps you will get Client Secret And Client Id)
3. Enter Connected App Name,API Name,Contact Email, and check Enable OAuth setting.
4. In 'Callback URl' , paste 'https://c.ap1.visual.force.com/apex/aouthWebServerFlow'.(this page will be of your org page and change url according to your instance)
5. In OAuth scopes ,Give 'Full Acess' as of now and save.


Let us know if it helps.
netspidernetspider
Hi Ashish

In the example there is a part of the code 

public aouthWebserverFlowController(){
       if(ApexPages.currentPage().getParameters().get('code')!=null){
           oAuthCode = ApexPages.currentPage().getParameters().get('code'); 
           string codeURL ='?code='+oAuthCode+'&grant_type=authorization_code';  
           uRLToGetAcessToken = baseTokenURL+codeURL+clientId+clientSecret+redirectURI;
       }
    }

Im not sure what the parameter code is. This is set to oAuthCode 
I cant see this is the client id or the secret because that is set to other variables

Steve