developerforce / Force.com-JavaScript-REST-Toolkit

ForceTK - a minimal Force.com REST API for JavaScript apps
BSD 3-Clause "New" or "Revised" License
315 stars 175 forks source link

Does ForceTK work with Partner users? #56

Closed d00001 closed 10 years ago

metadaddy commented 10 years ago

Yes, it should do, as long as the user's profile is API enabled. Please let me know if it works for you, so I can close the issue, or help diagnose any problems.

d00001 commented 10 years ago

I need it to work with partner portal users. I tried following what I think is your article: https://developer.salesforce.com/blogs/developer-relations/2013/02/oauth-for-portal-users.html

For some reason the url in the form

https://mysite.secure.force.com/services/oauth2/authorize?response_type=code&client_id=<your_client_id>&redirect_uri=<your_redirect_uri>

redirects to

login.salesforce.com/...

and partner portals users cannot authenticate. Only regular users. Do you have an idea why?

My code works fine for regular users.

metadaddy commented 10 years ago

That URL syntax should work. Could you email me the URL you're using so I can check it and see what the redirects look like? [email address removed]

d00001 commented 10 years ago

I found the problem I was calling the url with

?prompt=login&display=touch

I removed these and it worked.

Thanks

metadaddy commented 10 years ago

Great! Not sure why one or both of those parameters would cause it to break. I passed this on to the identity team at SFDC. Not an issue in the toolkit!

d00001 commented 10 years ago

Is the Username and Password flow supported for Partner portal users?

metadaddy commented 10 years ago

Not sure, and I don't have a partner portal handy to try it out - I'll ask the identity team. Fastest thing would be to try it yourself and see.

One thing that should work is SOAP login. You can specify the org id and portal id in the LoginScopeHeader, then use the resulting session id with the REST API. You'll just need to build and parse the XML.

d00001 commented 10 years ago

I tried but I get

authentication failure - Unknown exception: 1201

when trying portal users but it works fine for regular users.

I'm working on a phonegap app so I need it to work with javascript. I looked into the AJAX toolkit, does it work with external websites?

metadaddy commented 10 years ago

You'll have the same login issues with the AJAX toolkit - the problem is getting the token for a user.

You seemed to have the User Agent flow working. You should use this from a PhoneGap app, rather than username/password.