Explore Courses Blog Tutorials Interview Questions
0 votes
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?


from simple_salesforce import Salesforce

sf = Salesforce(instance_url='', session_id='')

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


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


File "C:\Python27\lib\site-packages\simple_salesforce\", 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.


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

Browse Categories