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
    Commented Feb 24, 2016 at 15:06
  • @crmprogdev edited the answer, I didn't add it earlier because I thought the it would imply it ;-) Thanks!!!
    – saurabh
    Commented Feb 24, 2016 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
    Commented Feb 24, 2016 at 21:08
  • @abhi but I could not find this stated clearly in documentation.
    – saurabh
    Commented Feb 25, 2016 at 6:42

1 Answer 1


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">
      <ns1:username>[email protected]</ns1:username>
  • thanks!! I will try this but we can't do this using REST API ?
    – saurabh
    Commented Feb 25, 2016 at 6:40
  • 1
    Hey it worked! But need to add portalId too. Also I had not activated profile for the organization.
    – saurabh
    Commented Feb 25, 2016 at 13:27
  • Hmm - that worked for me without portalId - I guess it depends on your config?
    – metadaddy
    Commented Feb 25, 2016 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/… Commented Nov 29, 2017 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .