salesforcesandboxpython-3.7simple-salesforce

Cannot login to Salesforce Sandbox via python API


I am using the python3.7.2 module simple-salesforce==0.74.2 and I am having trouble trying to establish a connection to my salesforce sandbox. I can login to the salesforce production with the same credentials just fine like so:

from simple_salesforce import Salesforce
sf = Salesforce(username='user@domain.com', password='pswd', security_token='mytoken')

Okay cool. Now I attempt to login to my sandbox with the following:

sf = Salesforce(username='user@domain.com.sandbox_name', password='pswd', security_token='mytoken', sandbox=True)

And I get the error:

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

So I tried logging in with a different method:

sf = Salesforce(username='user@domain.com.sandbox_name', password='pswd', security_token='mytoken', domain='sandbox_name')

And this gave a different error:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='sandbox_name.salesforce.com', port=443): Max retries exceeded with url: /services/Soap/u/38.0 (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))

I am using a Developer sandbox, named sandbox_name, following salesforce's instructions. Can someone give some advice on what I am doing incorrectly?


Solution

  • Solved. Set domain='test' and generate a new token under your sandbox account