+ Start a Discussion
Dan CahillDan Cahill 

Error trying to log into sandbox using PHP API call - INVALID_LOGIN: Invalid username, password, security token; or user locked out.

I've seen other posts regarding this issue and have tried them to the best of my ability, but no luck.

PHP code:
$USERNAME="XXX";
$PASSWORD="XXX";
$TOKEN="XXX";

require_once ('../forcecom/soapclient/SforcePartnerClient.php');
require_once ('../forcecom/soapclient/SforceHeaderOptions.php');

$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection("../forcecom/soapclient/partner.wsdl.xml");
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD . $TOKEN);

Every attempt always shows:

Fatal error: Uncaught SoapFault exception: [sf:INVALID_LOGIN] INVALID_LOGIN: Invalid username, password, security token; or user locked out.

So far I have tried the following:
  • Recreating the sandbox.
  • Resetting the password and the security token for two seperate accounts.  Both of these account can log into the sandbox using the browser successfully.
  • Changing the endpoint to <soap:address location="https://login.salesforce.com/services/Soap/u/32.0"/> 
Is there anything else that I should try?  Please help!
Dan CahillDan Cahill
I also should add that I have a seperate developer instance where I tested this and it worked without issue.  Is there possibly something that I set up incorrectly?
Sagar PareekSagar Pareek
From your WSDL  login request just remove this part
<urn:LoginScopeHeader>
        <urn:organizationId>?</urn:organizationId>
        <!--Optional:-->
        <urn:portalId>?</urn:portalId>
     </urn:LoginScopeHeader>
Dan CahillDan Cahill
Thanks for the reply Sagar - I tried your suggestion but still recieve the same message.
GauravTrivediGauravTrivedi
Try this https://developer.salesforce.com/page/Getting_Started_with_the_Force.com_Toolkit_for_PHP 

OR you can first go and check the profile for the user you try to login and check if API Enabled is checked.
User-added image
 
Dan CahillDan Cahill
Thanks for your reply Gaurav - I made a permission set just for the account that I am trying to use and granted it API access, but no change in results.

User-added image