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
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..
https
orhttp
?