Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Salesforce by (11.9k points)

I am trying to use simple_salesforce to query Salesforce data with Python. I am using my username and password, which I am 100% sure is correct. I got the org ID from logging into Salesforce and looking at my company profile. It's only a 15-digit ID. I am specifically using an orgID to avoid using a security token as I don't know what it is. What am I doing wrong?

Code:

from simple_salesforce import Salesforce

sf = Salesforce(instance_url='https://na1.salesforce.com', session_id='')

sf = Salesforce(password='password', username='email', organizationId='15 digit org id')

Output:

File "C:\Python27\lib\site-packages\simple_salesforce\api.py", line 100, in __init__

proxies=self.proxies)

File "C:\Python27\lib\site-packages\simple_salesforce\login.py", line 124, in SalesforceLogin

code=except_code, message=except_msg))

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

1 Answer

0 votes
by (32.1k points)

There is a way to log in with simple-salesforce with only a username and password. No security token required:

from simple_salesforce import Salesforce, SalesforceLogin

session_id, instance = SalesforceLogin(username='<user>', password='<pass>')

sf = Salesforce(instance=instance, session_id=session_id)

# Logged in! Now perform API actions, SOQL queries, etc.

sf.query_all('<soql>')

 Go for this in-depth job-oriented salesforce training online now!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...