4

I am trying to connect to Salesforce.com using their OAuth 2.0 interface. I have found solutions like LROAuth2Client that allow me to open a webpage and authenticate like that. But is there a way to do this all through the backend without going to a webpage first so I can have it more integrated into the App?

I am new to OAuth so I don't know all the limitations.

Thanks in advance.

sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161
smcdrc
  • 1,671
  • 2
  • 21
  • 29
  • Salesforce webauth is just a pants user experience on iPad, out of the box with their native SDK. Bar appears to tab between fields... really?? No way to get back from the forgot password help video page...really ?? Flashes a blank white screen before the blue page... ugh. – Bradley Thomas Feb 04 '14 at 16:04
  • Very detailed answer about this entire process here http://stackoverflow.com/questions/12794302/salesforce-authentication-failing/29112224 – Calvin Froedge Mar 18 '15 at 00:45

3 Answers3

6

Salesforce supports the OAuth2 username/password option, which is all done without a webpage. e.g. using curl you'd do

curl -v https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=xxxxxxxxxx" -d "client_secret=1234567890" -d "username=noreply@salesforce.com" -d "password=XXXXXXXXX"

Having said that, the web/interactive flow is pretty straightforward to use from iOS, using a custom scheme URL for the callback (trying to use a library is possibly making it harder than it actually is). The web based flow is important for users that are configured for alternative authentication flows (e.g. SAML based SSO), which won't work over the username/password flow.

There should be a video online somewhere of the REST & OAuth session from dreamforce'10, where the security PM wrote an iPhone oAuth client based app on stage.

superfell
  • 18,780
  • 4
  • 59
  • 81
  • 4
    Don't forget to add your security token on the end of your password here. – umassthrower Feb 20 '11 at 22:27
  • @superfell, i have question here.I have also used same LROAuth2Client library for application.I have successfully loged in and get Json data returned by SalesForce.Now i need to display user info in some webpage and i have user id and latest access token.Now i am calling this url to show the user: https://login.salesforce.com/id/orgID/userID&access_token=XXXXXXXXXXXXX which i get after successful authentication.Now the Issue is,every time i call the url it shows me Error:Missing_OAuth_Token,although i have provided this in url in access_token parameter.So i am confused,what i am doing wrong ? – Sandeep Singh Mar 19 '13 at 06:12
0

It depends on your goal. One reason for using oauth2 is you want better insight into what is is running. Lets say for example you have many cron API applications all connecting to the same site. In that case, since they are cron applications, you don't even necessarily have a web browser running on your cron servers. You could of course just configure username and password, but then if you have a password reset you have to update all your cron servers, and you don't even necessarily know how many servers that is. Especially if they are coming through a NAT.

In this type of scenario, a very workable solution is to use a visual force page on salesforce as the callback URL. The administrator can login salesforce and then use the visual force page to generate a refresh token, they then hand off for use with the cron job.

You know have oauth 2 in your auditing stage. The token you have handed out, can be restricted to API. And hopefully if salesforce has don't oauth 2 correctly, you can reset the password on the user login as often as need be, without effecting the tokens you have handed out.

Bill

Bill
  • 361
  • 3
  • 4
0

There is one more approach to this. You can visit my site for the approach.

ipradhansk
  • 352
  • 1
  • 10
  • 36