Cannot login to Salesforce Sandbox via python API

0 votes

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')

 Now I attempted 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?

Mar 1, 2022 in SalesForce by surbhi
• 3,810 points
1,432 views

1 answer to this question.

0 votes

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

Elevate your career as a Salesforce Platform Developer with the industry-leading Salesforce Platform Developer1 Certification.

answered Mar 1, 2022 by CoolCoder
• 4,400 points

Related Questions In SalesForce

0 votes
0 answers

How to take test.salesforce.com while deployment as salesforce login url for api connection logic app?

In logic app i'm using salesforce connector after deployment ...READ MORE

Mar 1, 2022 in SalesForce by surbhi
• 3,810 points
826 views
0 votes
1 answer

How to take test.salesforce.com while deployment as salesforce login url for api connection logic app?

you are not passing the parameterValues, use ...READ MORE

answered Mar 2, 2022 in SalesForce by surbhi
• 3,810 points
763 views
0 votes
1 answer

Salesforce Streaming API: Recconnect to Cometd after session expires

I'm responding from the perspective of CometD. Doing ...READ MORE

answered Mar 17, 2022 in SalesForce by CoolCoder
• 4,400 points
509 views
0 votes
1 answer

how to find the difference between sandbox and production in salesforce

It could be a validation rule or ...READ MORE

answered Apr 1, 2022 in SalesForce by CoolCoder
• 4,400 points

edited Jun 27, 2023 by Khan Sarfaraz 1,144 views
+2 votes
2 answers

Salesforce Interview questions

Here are some questions very important for ...READ MORE

answered Jan 11, 2019 in Career Counselling by Suresh
• 720 points
2,775 views
0 votes
1 answer

How to connect to salesforce from tableau?

Hi, follow these steps to connect to Salesforce: 1. ...READ MORE

answered Mar 25, 2019 in Tableau by Cherukuri
• 33,030 points
748 views
0 votes
1 answer

Power BI - Salesforce

Hi, Follow below steps: 1. Go to Data source. 2. ...READ MORE

answered Mar 25, 2019 in Power BI by Cherukuri
• 33,030 points
486 views
0 votes
2 answers

What is the best training for Salesforce ADM-201 Exam?

Hi @Vardhan, I took Edureka's Salesforce Online Training, ...READ MORE

answered Jun 3, 2021 in Others by Jaya
• 140 points

edited Dec 22, 2021 by Soumya 549 views
0 votes
1 answer

How to take test.salesforce.com while deployment as salesforce login url for api connection logic app?

You are not passing the parameterValues, use ...READ MORE

answered Mar 9, 2022 in SalesForce by CoolCoder
• 4,400 points
580 views
0 votes
1 answer

How to log into a salesforce.com sandbox?

My user account was created after the ...READ MORE

answered Mar 15, 2022 in SalesForce by CoolCoder
• 4,400 points

edited Jun 19, 2023 by Khan Sarfaraz 1,257 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP