function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jason_lowryjason_lowry 

Can't login to sandbox via API after refresh

Hello,

I'm stuck and hoping someone can help. I refreshed my sandbox and I can login via the web but cannot log in via the API. I use Eclipse for Force development and can't reconnect. I also tried via the PHP soapclient - which is what we use internally - and get the same error. Following the refresh I logged in and reset my security token. I've tried this three times but it continues to fail. Like I said, I can log in normally but not through the API so it suggests a problem with the security token or API. I am using a default System Administrator profile that has API Enabled checked by default.

<?php
require_once ('soapclient/SforceEnterpriseClient.php');
define("USERNAME", "jason@finch.com.dev");
define("PASSWORD", "XXXXXXXX");
define("SECURITY_TOKEN", "XXXXXXXXXXXXXXXXXXXXX");
$mySforceConnection = new SforceEnterpriseClient();
$wsdl = 'soapclient/enterprise.wsdl.xml';
$mySforceConnection->createConnection($wsdl);
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
$query = "select email from user";
$result = $mySforceConnection->query($query);
print_r($result);
?>

This works on production but fails in the sandbox with the following error:
Fatal error: Uncaught SoapFault exception: [INVALID_LOGIN] INVALID_LOGIN: Invalid username, password, security token; or user locked out. in /Applications/XAMPP/xamppfiles/htdocs/trunk/plugins/system/salesforce/soapclient/SforceBaseClient.php:168

Any other suggestions? 
PrasanntaPrasannta (Salesforce Developers) 
Hi,

If a login call is made from the API for a user with an expired or temporary password, subsequent API calls to custom Apex SOAP Web service methods aren't supported and result in the INVALID_OPERATION_WITH_EXPIRED_PASSWORD error. Reset the user's password and make a call with an unexpired password to be able to call Apex Web service methods.
jason_lowryjason_lowry
Thanks for the help. I reset the password, got the email with the new security token, then updated the script with the new password and new token. Unfortunately I got the same result. I can login with the new password, but can't access via the API. 

Any other suggestions? 
Anil KamisettyAnil Kamisetty
Hi Jason

Are you sure that the Sandbox name is not changed ? By any chance did you change your User name ?
jason_lowryjason_lowry
As I mentioned, I can log into Salesforce via the browser without an issue using the username appended with the sandbox name. Perhaps I need to delete this sandbox and try again?
Anil KamisettyAnil Kamisetty
This should be the last step.

1. If the User name is correct, try adding your IP address to the Trusted Sites. Thus Security Code is not mandatory

If this does not work, refreshing the sandbox one more time seems the choice. Probably create this time with a different name.
nbknbk
Can you verify below steps.
1 - login into sandbox via web and check the personnel information [some times 'user Locked' button apper, if yes click 'UnLock']
2- set the Login IP ranges for system admin profile (profiles->system admin profile->login ip ranges ->
start ip - 0.0.0.0 end ip - 255.255.255.255)

3 - login via data loader without security token hence we added ip address and we can able to login!!
jason_lowryjason_lowry
Thank you for the ideas and responses. Ultimatly, I deleted the sandbox and created a new one using a different name. After that I reset my security token, added my IP to the trusted IPs and was able to login via the API using Eclipse (my IDE). However, I still can't login via my PHP (which is OK for now). 

This thread also said that I had to update my WSDL endpoint, which makes sense - but still didn't work for me.
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008pAhIAI

Thanks for your help.
Anil KamisettyAnil Kamisetty
Hi Jason

Sandbox url is Test.Salesforce.com where as Production is Login.Salesforce.com. Only possibility is that you are using the Sandbox Credentials to login Production URL (Login.Salesforce.com). Can you make sure if you are using the sandbox url only ?

In the place of Sandbox credentials, try using the Production credentials. If it logs you in, then the url is Produciton for sure.
Matt WhalleyMatt Whalley
Finding this is happening since spring '14.  Found some work arounds though:
  1. Change your username
  2. Specify your domain in the login URL (cs3.salesforce.com)
It's almost like the login via test.salesforce.com has cached the old sandbox user, so any attempt via test instead of the specific cs hits the old one.  This really needs to be fixed, because some tools don't let you specifiy your own URL (like real force explorer - which is awesome by the way).  Your solution is much the same by specifying a different sandbox name, thus creating a different username.
Robert KürzingerRobert Kürzinger
Don't know if this is relevant for the original question, but I solved my "Invalid username, password, security token; or user locked out." problem thanks to Matt's suggestions.
Updating my ant build.properties file to the actual subdomain helped, so instead of using test.salesforce.com as serverurl I used cs8.salesforce.com

Chris RichardChris Richard
Matt - Thank you for saving me another 5 hours of pulling my hair out! I kept thinking it couldn't be the endpoint and that I must be doing something wrong but changing my username worked immediately.

Please fix this soon!
DRahlfDRahlf
Thanks Matt - great advice. It worked immediately even with test.salesforce.com.
Kendall BuchananKendall Buchanan
Yes, changing the login URL from test.salesforce.com to whatever new URL was provided fixed it for me as well. Thank you!
Matthew MitchenerMatthew Mitchener
Had same issue, chaning username as Matt suggested worked for me too! Thanks so much