I am using simple-salesforce 0.74.2 for connecting to Salesforce by using below code,

from simple_salesforce import Salesforce,SalesforceLogin
sf = Salesforce(instance_url='https://xxxxx-xxx.my.salesforce.com', username='xxx@xxx.com.xxx', password='xxx@12345')

Getting below error:

You must provide login information or an instance and token' TypeError: You must provide login information or an instance and token

Note: We are using Single sign on so we do not have Token available in Salesforce due to that I can't use token, I want a way where I can login using Authorization may be header but not sure how to pass it.

any help is really appreciated


simple_salesforce does not provide support for Oauth authentication. It handles authentication via the SOAP API.

Your options are:

  • Authenticate with simple_salesforce using username, password, and Organization Id. This works if you have IP whitelisting in use and obviates the need for a security token. (I am not familiar with any SSO implications here, however).

    sf = Salesforce(instance_url='https://xxxxx-xxx.my.salesforce.com', username='xxx@xxx.com.xxx', password='xxx@12345', organizationId='MY_ORG_ID')
  • Authenticate with username, password, and security token. It sounds like you would need to make changes to your organization's configuration to do that.

  • Authenticate out-of-band, using some other tool or manually authenticating and extracting your session Id, and provide simple_salesforce with a valid Session Id and Instance URL.

    sf = Salesforce(instance_url='https://my.instance.salesforce.com', session_id='XXXXXXX')

    There's a discussion of this approach (although without a lot more detail) on the simple_salesforce GitHub. I've implemented JWT Oauth authentication outside of simple_salesforce and provided the session Id this way, and it works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.