function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sneha KavinkarSneha Kavinkar 

key error : access_token

Hello,
I am using beatbox and salesforce-reporting module for login and downloading reports using python.
I was able to login successfully however when i try to pull reports using salesforce-reporting it gives me following error
File "C:\Admin\Python27\lib\site-packages\salesforce_reporting\login.py", line  17, in __init__     
self.token = self._get_token(payload)   
File "C:\Admin\Python27\lib\site-packages\salesforce_reporting\login.py", line  25, in _get_token     
return token_request.json()['access_token'] 
KeyError: 'access_token'
Seems like my authentication is not successful for pulling reports.
I double checked my credentials and everything is proper except for last parameter 
my_sf = salesforce_reporting.Connection('your_id', 'your_secret', 'your_username', 'your_password', 'your_instance')
I was not sure what should be value for 'your_instance' hence added dummy value ''na32.salesforce.com''.
Can anyone please guide what should i put for 'your_instance' and what should be possible cause of my error.
Thanks in advance
pconpcon
I believe you will want to use "https://login.salesforce.com" or "https://test.salesforce.com" depending on if you are connecting to a production or sandbox instance.  Based on the fact that you mention na32, you will want to use the first.
Sneha KavinkarSneha Kavinkar
Thanks for the reply! but it still gives me 'access_token' error
Sumir Saini 14Sumir Saini 14
Sneha - you need to create a connected app in your org and make sure to change your oauth policy to "All users may self-authorize"

Instructions on how to create the connected app here: https://edgecate.com/articles/sfdc/