0

I have to connect two different sales force org am getting error for 400 and 302 and bad request. Where do I get refresh token, Please can you give suggestion what correction should I do?

httprequest hreq=new httprequest(); //string
refresh_url='https://login.salesforce.com/services/oauth2/token?grant_type=refresh_token&client_id=3MVG9Y6d_Btp4xp7AyV8b3ouuXI_CkGlTRIJLDmriyEpT59eoFmWPZBwjZmoI8Raq3cRrYzFZ.Oa9ZpBayp87&client_secret=3678419209862860540&refresh_token=0Ak900000GcOb09';
string
refresh_url='https://login.salesforce.com/services/oauth2/authorize?response_type=token+id_token&client_id=3MVG9Y6d_Btp4xp7AyV8b3ouuXI_CkGlTRIJLDmriyEpT59eoFmWPZBwjZmoI8Raq3cRrYzFZ.Oa9ZpBayp87&redirect_uri=https://login.salesforce.com/services/oauth2/success';
    system.debug('------------refresh_url------------'+refresh_url); hreq.Setendpoint(refresh_url); hreq.setmethod('POST');
 hreq.setHeader('Accept',
 'application/application/x-www-form-urlencoded;charset=UTF-8');
 hreq.setHeader('Host','ap1.salesforce.com'); http htp=new http();
 httpResponse res=htp.send(hreq); 

 System.debug('-----------------FutureRefreshToken_ID------------------'
 +res.getBody()); //string result=readXMLResponseOfFutureAccessToken(res.getBody());
0

Both Webserver flow & User Agent Flow provides you with a response with Refresh token which can be used in your further calls.

https://help.salesforce.com/HTViewHelpDoc?id=remoteaccess_oauth_user_agent_flow.htm&language=en_US

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.