I have a need to query salesforce data through a django app. I am currently using simple-salesforce to do this on our QA salesforce using a username, password and a security token. Now that I am moving on to the production environment, I need to use oAuth. I have a Client ID and a Client Secret from the connected app.
I have tried these variations with failed authentication results:
session_id, instance = SalesforceLogin(username=username,
password=password, security_token=token, organizationId=org_id)
sf = Salesforce(instance=instance, session_id=session_id)
and
sf = Salesforce(instance_url=instance_url, username=username, password=password, security_token=token)
I do see that simple-salesforce supports JWT Bearer flow but I do not have a private key.
Best Answer
Instead of going for Simple_Salesforce package try doing it through Request package.Here is piece of code i did in my project.
I am using a config.ini files PARAMS values.
Code to get the access token:
authorization_response.json() will contain the access token, which can be utilise throughout the session as OAuth token for communicating with salesforce.