intercom / python-intercom

Python wrapper for the Intercom API.
https://keyes.ie/things/python-intercom/
Other
235 stars 143 forks source link

DeprecationWarning: Non-string usernames will no longer be supported in Requests 3 #187

Open michael-k opened 6 years ago

michael-k commented 6 years ago

DeprecationWarning: Non-string usernames will no longer be supported in Requests 3.0.0. Please convert the object you've passed in (None) to a string or bytes object in the near future to avoid problems.

https://github.com/requests/requests/blob/f3fc892b901abe2c3605f2669af4f6469b896e88/requests/auth.py#L38-L45

Maybe Client._auth should return a function that does the same as HTTPBasicAuth.__call__?

https://github.com/intercom/python-intercom/blob/60b14138445d80e165745abe1a3754d250b7d1de/intercom/client.py#L14-L16

michael-k commented 6 years ago

Stacktrace:

    user = intercom_client.users.find(email=email)
  File "/usr/local/lib/python3.6/site-packages/intercom/api_operations/find.py", line 19, in find
    response = self.client.get("/%s" % (collection), params)
  File "/usr/local/lib/python3.6/site-packages/intercom/client.py", line 91, in get
    return self._execute_request(req, params)
  File "/usr/local/lib/python3.6/site-packages/intercom/client.py", line 84, in _execute_request
    result = request.execute(self.base_url, self._auth, params)
  File "/usr/local/lib/python3.6/site-packages/intercom/request.py", line 36, in execute
    return self.send_request_to_path(base_url, auth, params)
  File "/usr/local/lib/python3.6/site-packages/intercom/request.py", line 75, in send_request_to_path
    auth=auth, verify=certifi.where(), **req_params)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 494, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 437, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 309, in prepare
    self.prepare_auth(auth, url)
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 540, in prepare_auth
    r = auth(self)
  File "/usr/local/lib/python3.6/site-packages/requests/auth.py", line 96, in __call__
    r.headers['Authorization'] = _basic_auth_str(self.username, self.password)
  File "/usr/local/lib/python3.6/site-packages/requests/auth.py", line 44, in _basic_auth_str
    category=DeprecationWarning,
DeprecationWarning: Non-string usernames will no longer be supported in Requests 3.0.0. Please convert the object you've passed in (None) to a string or bytes object in the near future to avoid problems.
killthekitten commented 5 years ago

I realized we had this warning in test environment only, and the quick fix was, well, to override the test config and set it to something other than None. Is that the case for you as well?