pythonsalesforcesalesforce-communitiessimple-salesforce

simple_salesforce whitelisted IP authentication doesn't work


I'm using simple-salesforce 1.11.5 to connect to a Salesforce account, my code is exactly what their sample code for whitelisted IP access is:

from simple_salesforce import Salesforce
sf = Salesforce(password='correctpwd', username='correctuser', organizationId='correctorgid')

And I got this error:

simple_salesforce.exceptions.SalesforceAuthenticationFailed: INVALID_LOGIN: Invalid username, password, security token; or user locked out.

Using the same set of credential, I was able to log in to Salesforce through browser, so I think my IP is whitelisted for sure. Am I missing any configuration step? Really thank you in advance for your insight and suggestions!


Solution

  • Turns out I need to leave security_token empty even there isn't one. Also, this account is a sandbox, so I need to provide 'test' as the domain. In the end, this worked:

    from simple_salesforce import Salesforce
    sf = Salesforce(password='correctpwd', 
                    username='correctuser', 
                    organizationId='correctorgid',
                    security_token='',
                    domain='test')