5

I am following web-server authorization flow for establishing the connection between one org to another org. as a 1st step i have get authorization code,when i am proceeding to 2nd step, getting above error. I have already set remote site access setting is as follow in source org. https://login.salesforce.com, and https://ap1.salesforce.com as a instance url. my request code is:


//getting authorization code
string codeparam=apexpages.currentpage().getparameters().get('code');
Http h = new Http();
String body='grant_type=authorization_code&code='+codeparam+'&client_id='+CLIENT_ID+'&client_secret='+CLIENT_SECRET+'&redirect_uri='+REDIRECT_URL;
HttpRequest req = new HttpRequest();
req.setEndpoint('https://login.salesforce.com/services/oauth2/token');
// req.setHeader('Content-Type','application/json');
// req.setHeader('accept','application/json');
req.setMethod('POST');
req.setBody(body);
HttpResponse res = h.send(req);

.......anybody can help. screen shot my remote access setting

enter image description here

can any one get this i am not getting the login page,its directly ask for approve the page , as a user from which i am sending the request..if i changed the user to source user then it logout me from destination org ..if i logout then i cannot get that authorization code. :( here is snap shot of that stage..enter image description here enter image description here

7
  • 1
    Can you show us a screen shot of the Remote Site Settings screen? Is it https or http? Commented Jan 31, 2014 at 13:56
  • @AbhinavGupta :i didn't get why its telling like "Remote site Setting.endpoint...i am setting enpoint in request.setEndpoint
    – Ankuli
    Commented Jan 31, 2014 at 14:41
  • Is this in the client org or the service org? Commented Jan 31, 2014 at 14:53
  • @user320..my source org(service org) [email protected] destination org(client org) [email protected] now you will get clear image of my problem
    – Ankuli
    Commented Jan 31, 2014 at 15:03
  • 4
    I'm voting to close this question as off-topic because Abandoned
    – Eric
    Commented Sep 25, 2016 at 22:27

1 Answer 1

0

Have you define your org from where you are requesting, in Connected App to the Resource.If you are using salesforce org1 as a client and salesforce org2 as a Server than Define Connected app in salesforce org2 which you are using as a Server.

Not the answer you're looking for? Browse other questions tagged .