Is it possible to log a Communities user in via the Username-Password Auth Flow?
With normal users you can call the http://test.salesforce.com/services/oauth2/token
and passing the username, password, client id, client secret and grant type you can get an access token back.
So would the communities version of this url be https://<MySandbox>.cs14.force.com/<CommunityName>/services/oauth2/token
2 Answers
Yes you need to change the base URL to make it working. Here is a sample URL for you.
https://mysite.secure.force.com/services/oauth2/authorize?response_type=code&client_id=<your_client_id>&redirect_uri=<your_redirect_uri>
The authorization service will recognize the custom hostname and further redirect the user to the Site login page, assuming the user is not yet authenticated. Note – if your site uses a path as well as the site domain, for example, https://mysite.secure.force.com/mypath, you will need to include that path in the authorization URL:
https://mysite.secure.force.com/mypath/services/oauth2/authorize?response_type=code&client_id=<your_client_id>&redirect_uri=<your_redirect_uri>
-
This is what I am currently using, but the redirect is not the desired result. I was hoping to just get an access token like you can for normal users, and then use that token in subsequent calls. Sep 13, 2017 at 9:12
Oauth Username-Password flow does not support community user.
SF docs: Experience Cloud sites don’t support the OAuth 2.0 username-password flow
-
Welcome to SFSE! Can you share any references or documentation to improve this asnwer?– David Reed ♦Apr 25 at 1:34