HTTPDigestAuth fails on non-latin credentials
Author: ondratuCreated Apr 4, 2022Updated Sep 5, 2026
LabelsBug
There was issue reported, which is closed with bad results.
Don't pass unicode strings in the arguments, but use UTF8 bytes instead.
self.session.get(main_url, auth=requests.auth.HTTPDigestAuth("Сергей_Ласточкин".encode('UTF-8'), '1234'))
Originally posted by @D-stefaang in https://github.com/psf/requests/issues/5089#issuecomment-763569911
But this is wrong! When i try to set user 'Ondřej' with this advice, requests send bad string:
HTTPDigestAuth('Ondřej'.encode('utf-8'), 'heslíčko')
creates header starts with wrong username!
Digest username="b'Ond\xc5\x99ej'"
Source: psf/requests