25def _basic_auth_str(username, password):
26 """Returns a Basic Auth string."""
27
28
29
30
31
32
33
34
37 "Non-string usernames will no longer be supported in Requests "
38 "3.0.0. Please convert the object you've passed in ({!r}) to "
39 "a string or bytes object in the near future to avoid "
40 "problems.".format(username),
41 category=DeprecationWarning,
42 )
43 username = str(username)
44
47 "Non-string passwords will no longer be supported in Requests "
48 "3.0.0. Please convert the object you've passed in ({!r}) to "
49 "a string or bytes object in the near future to avoid "
50 "problems.".format(type(password)),
51 category=DeprecationWarning,
52 )
53 password = str(password)
54
55
58
61
62 authstr = "Basic " + to_native_string(
63 b64encode(b":".join((username, password))).strip()
64 )
65
66 return authstr
67
68