You need to sign in to do that
Don't have an account?
Arpit
Using rest api with Web Server OAuth Authentication Flow
Hi,
I have a requirement where i need to send data from one sales force ORG to other Sales force ORG using rest api.
But here in this i want to use Web Server OAuth Authentication Flow for providing authentication for this.
I need help in this on how to get it started.If someone can post some demo code for this then that will help a lot.
I am having Client ID,Secret ID and redirect_uri that we requires but i am facing issue in generating Token within my apex class and fetch and use that token so that i can move ahead.
Any help on the same is Highly Appreciated.Looking ahead for an Quick response.
Thanks in Advance !!
Arpit
I have a requirement where i need to send data from one sales force ORG to other Sales force ORG using rest api.
But here in this i want to use Web Server OAuth Authentication Flow for providing authentication for this.
I need help in this on how to get it started.If someone can post some demo code for this then that will help a lot.
I am having Client ID,Secret ID and redirect_uri that we requires but i am facing issue in generating Token within my apex class and fetch and use that token so that i can move ahead.
Any help on the same is Highly Appreciated.Looking ahead for an Quick response.
Thanks in Advance !!
Arpit
When user clicks a button - call this method in apex controller
In your Apex page, add an action method, something like this (see how OAuthAccess method is listed)
In your Apex controller define OAuthAccess like below
The Response Class is where you have the instance uRl and the session Id that you can use in subsequent calls.
Hope this helps..
Thanks for your quick reply
I have tried already what you mention in above code The issue is that when i am trying to give the "Pagereference OAuthPage = new Pagereference(oSettings.OAuthURL__c + '&client_id='+oSettings.ClientId__c+'&redirect_uri='+oSettings.RedirectURI__c);" URL in my page reference i am not recieving token in Oauth Access method and only getting same URL in debug log but when i am trying the same from UI then i cann see the code in URL but unable to fetch that in my class.
Can you please help me with this?
Thanks.
Arpit
Hmm. that code in URL is a URL Parameter, so you need to do Apexpages.currentPage().getParameters().get('code'). But you might have already done this. Did you setup the method as part of <apex:page> ?
If possible can you post your code so that I can see where its going wrong?
Thanks for all your support.
Now i am facnig the issue after i get Access token and send the data by having that in setheader.
I am getting response error of 401 saying that Session is Invalid.Can you please help me with the same?
Looking for quick response
Thanks.
Arpit