Open lstrupinskaya opened 10 years ago
Hi Scott,
Thank you for creating this module. It was very helpful to me.
I have found two issues with it that I fixed locally in my download and would like to have them incorporated into main library.
Below is modifications I made to the code that could be incorporated into code to fix these issues:
if not os.environ.has_key('HOME'): os.environ['HOME'] = os.path.join(os.environ['HOMEDRIVE'], \ os.environ['HOMEPATH'])
inside website_login procedure I added a check for sandbox parameter and redirect to test.salesforce.com if it is true:
def website_login(username = None, password = None, client_id = None, client_secret = None, redirect_uri = None, sandbox = None, cache_session = None, state = None): base = "https://login.salesforce.com" if not sandbox else "https://test.salesforce.com" auth_url = base + "/services/oauth2/authorize?"
client_id = os.environ.get('SALESFORCE_CLIENT_ID', client_id) client_secret = os.environ.get('SALESFORCE_CLIENT_SECRET', client_secret) redirect_uri = os.environ.get('SALESFORCE_REDIRECT_URI', redirect_uri) auth_url += urllib.urlencode([ ("response_type", "code"), ("display", "popup"), ("client_id",client_id), ("redirect_uri", redirect_uri), ("prompt", "login"), ("state", state)]) s = requests.session() redirect_return = oauth_flow(s, auth_url, username=username, password=password) # parse out the session id and endpoint params = urlparse.parse_qs(redirect_return) data = dict(code=params['code'], grant_type="authorization_code", client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri, format="json") code_url = base + "/services/oauth2/token" return requests.post(code_url, data=data)
I think #2 solved this
Hi Scott,
Thank you for creating this module. It was very helpful to me.
I have found two issues with it that I fixed locally in my download and would like to have them incorporated into main library.
Below is modifications I made to the code that could be incorporated into code to fix these issues:
inside website_login procedure I added a check for sandbox parameter and redirect to test.salesforce.com if it is true:
def website_login(username = None, password = None, client_id = None, client_secret = None, redirect_uri = None, sandbox = None, cache_session = None, state = None): base = "https://login.salesforce.com" if not sandbox else "https://test.salesforce.com" auth_url = base + "/services/oauth2/authorize?"