Advertisement
Guest User

Untitled

a guest
Oct 9th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import urllib2
  2.  
  3. url = 'https://test.salesforce.com/services/oauth2/token'
  4. data = '&grant_type=password&client_id='+CLIENT_ID+'&client_secret='+CLIENT_SECRET+'&username='+username+'&password='+password
  5. headers = {'X-PrettyPrint' : '1'}
  6.  
  7. req = urllib2.Request(url, data, headers)
  8. res = urllib2.urlopen(req) #this is where it fails!
  9.  
  10. Traceback (most recent call last):
  11. File "<stdin>", line 1, in <module>
  12. File "C:Python27liburllib2.py", line 126, in urlopen
  13. return _opener.open(url, data, timeout)
  14. File "C:Python27liburllib2.py", line 397, in open
  15. response = meth(req, response)
  16. File "C:Python27liburllib2.py", line 510, in http_response
  17. 'http', request, response, code, msg, hdrs)
  18. File "C:Python27liburllib2.py", line 435, in error
  19. return self._call_chain(*args)
  20. File "C:Python27liburllib2.py", line 369, in _call_chain
  21. result = func(*args)
  22. File "C:Python27liburllib2.py", line 518, in http_error_default
  23. raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
  24. urllib2.HTTPError: HTTP Error 400: Bad Request
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement