+ Start a Discussion
mohaaronmohaaron 

OAuth for remote access within Salesforce app

I'm in the process of building a native Salesforce app that needs to allow a remote site to connect using OAuth. What I would like to do is allow an administrator to authorize the connection from within the Salesforce app using either the web server flow or the user-agent flow. It seems as though OAuth only works if it's done from a external site. Does anyone know if it's possbile to do this from within Salesforce by and admin or some way I can use apex code to make this work?

 

Thank you

Navatar_DbSupNavatar_DbSup

Hi,

 

Use remote access to specify remote access applications. For this go to App Setup ->Develop ->Remote Access -> Click on new button. After creating new remote access you will get Consumer Key and Consumer Secret.

 

Now for Authentication you can make use of OAuth 2.0. Salesforce.com introduced support for Draft 10 of OAuth 2.0 in the winter '11 release of Force.com; this version continues to be supported in spring '11.

 

After Authentication we can make use of REST API's for sending request.

 

For more details regarding REST Api follow the below links

http://www.salesforce.com/us/developer/docs/api_rest/api_rest.pdf

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

mohaaronmohaaron

Thank you for the response.

 

I've done a lot of reading and have made some tests trying to do what I want and so far nothing has worked to solve my specific problem.

 

Specifically, is it possible to do this within a Salesforce app. It seems that the process for having a user authenticate an external application is specifically designed to be done from outside of salesforce from the external site. I need to have a salesforce admin do this from within salesforce.

 

It seems that to make this work I have to redirect the user to https://login.salesforce.com/services/oauth2/authorize?display=popup&response_type=code&client_id=******&redirect_uri=https://login.salesforce.com/services/oauth2/success so that the user can authenticate the request, once done salesforce redirects again to the redirect_url which is where I'm supposed to capture the authentication token as well as the refresh token.

 

So the problem I'm having is how to do this from within my salesforce app?