python-intercom icon indicating copy to clipboard operation
python-intercom copied to clipboard

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

Open michael-k opened this issue 7 years ago • 2 comments

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 avatar May 16 '18 16:05 michael-k

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.

michael-k avatar May 16 '18 16:05 michael-k

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?

killthekitten avatar Jun 13 '19 10:06 killthekitten