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
https://my-domain-1-developer-edition.ap2.force.com/investor/services/oauth2/token
params
client_id,client_secret,username,password,
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
https://my-domain-1-developer-edition.ap2.force.com/investor/services/Soap/u/36.0
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<n1:login xmlns:n1="urn:partner.soap.sforce.com">
<n1:username>username</n1:username>
<n1:password>password</n1:password>
</n1:login>
</env:Body>
</env:Envelope>
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">
<soapenv:Body>
<soapenv:Fault>
<faultcode>sf:INVALID_LOGIN</faultcode>
<faultstring>INVALID_LOGIN: Invalid username, password, security token; or user locked out.</faultstring>
<detail>
<sf:LoginFault xsi:type="sf:LoginFault">
<sf:exceptionCode>INVALID_LOGIN</sf:exceptionCode>
<sf:exceptionMessage>Invalid username, password, security token; or user locked out.</sf:exceptionMessage>
</sf:LoginFault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
I am using developer license.
Best Answer
Since community usernames are not globally unique, you need to use SOAP login with LoginScopeHeader to identify the org: