I want to login a customer community user using rest api or at least using soap api.

I have created a user using the REST API. To create the user, first I created one contact with account and provided the profile id of a cloned profile of type community login user with api enabled option.

To Login user, I used the URL



grant_type="password", response_type="code",content-type="application/x-www-form-urlencoded"

got response

  "error": "unsupported_grant_type",
  "error_description": "grant type not supported"

I have also tried to set 'application/x-www-form-urlencoded' as content-type. in header.

I have also tried to do it using SOAP endpoint


<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    <n1:login xmlns:n1="urn:partner.soap.sforce.com">

got the response

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <faultstring>INVALID_LOGIN: Invalid username, password, security token; or user locked out.</faultstring>
                <sf:LoginFault xsi:type="sf:LoginFault">
                    <sf:exceptionMessage>Invalid username, password, security token; or user locked out.</sf:exceptionMessage>

I am using developer license.

  • Hi saurabh, welcome to SFSE! Please take the time to visit the Help center and read How do I ask a good question. It's not clear to me exactly what your question is. If you post what you've written so far and where you're stuck, I'm confident you'll find plenty of people willing to assist you. – crmprogdev Feb 24 '16 at 15:06
  • @crmprogdev edited the answer, I didn't add it earlier because I thought the it would imply it ;-) Thanks!!! – saurabh Feb 24 '16 at 15:26
  • @saurabh It is not possible to login with the community user credentials as you would with a regular user. OAuth has different flows. The username / password flow is not supported for community user. – abhi Feb 24 '16 at 21:08
  • @abhi but I could not find this stated clearly in documentation. – saurabh Feb 25 '16 at 6:42

Since community usernames are not globally unique, you need to use SOAP login with LoginScopeHeader to identify the org:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:partner.soap.sforce.com">
| improve this answer | |
  • thanks!! I will try this but we can't do this using REST API ? – saurabh Feb 25 '16 at 6:40
  • 1
    Hey it worked! But need to add portalId too. Also I had not activated profile for the organization. – saurabh Feb 25 '16 at 13:27
  • Hmm - that worked for me without portalId - I guess it depends on your config? – metadaddy Feb 25 '16 at 19:25
  • my community user is not able to login using the above solution so I have posted a similar question on the community salesforce.stackexchange.com/questions/200408/… – harshal jadhav Nov 29 '17 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.