You need to sign in to do that
Don't have an account?
Puneet Khosla
Http request from browser works fine but not from apex
I have a http request (to an external system) which is returning a valid json response when I put it in browser, but when I try to use the http request from code, it doesn't work.
It further looks that when it returns, its actually taking to the salesforce Remote Authorization page, thus causing a redirect.
Is there are way to proceed further when this Redirect Authorization page is coming in apex or what do I need to pass in the http request (I added the Header Authorization : 'OAuth' + UserSessionid in the request from salesforce to the api.
Debug statement of Response.getBody();
==
if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('https://test.salesforce.com/?ec=302&startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3Dsdjfnsdjkfbjsdfbsdbfsdjhbfhsdbf'); } else
if (window.location.replace){
window.location.replace('https://test.salesforce.com/?ec=302&startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3D.............
==
It further looks that when it returns, its actually taking to the salesforce Remote Authorization page, thus causing a redirect.
Is there are way to proceed further when this Redirect Authorization page is coming in apex or what do I need to pass in the http request (I added the Header Authorization : 'OAuth' + UserSessionid in the request from salesforce to the api.
Debug statement of Response.getBody();
==
if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('https://test.salesforce.com/?ec=302&startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3Dsdjfnsdjkfbjsdfbsdbfsdjhbfhsdbf'); } else
if (window.location.replace){
window.location.replace('https://test.salesforce.com/?ec=302&startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3D.............
==
I am calling php service from apex using http request.
I am giving the end point, parameters, etc.
When I initiate the http request from apex, it calls the php service.
php service tries to authenticate from salesforce (for a genuine request) and thus sends the request to get authorization
/services/oauth2/authorize?response_type=code&client_id=
However this is where Salesforce gets stuck at the RemoteAccessAuthorizationPage in the response.
I suppose you would have already gone through few posts, can you refer the below post and check your code with it?
http://salesforce.stackexchange.com/questions/8208/bypassing-remoteaccessauthorizationpage-when-using-a-remote-application