mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
httpbasic authentication cleanup
This commit is contained in:
+4
-2
@@ -7,15 +7,17 @@ requests.auth
|
||||
This module contains the authentication handlers for Requests.
|
||||
"""
|
||||
|
||||
from base64 import encodestring as base64
|
||||
from base64 import base64
|
||||
|
||||
def http_basic(r, username, password):
|
||||
"""Attaches HTTP Basic Authentication to the given Request object.
|
||||
Arguments should be considered non-positional.
|
||||
|
||||
"""
|
||||
username = str(username)
|
||||
password = str(password)
|
||||
|
||||
auth_s = base64('%s:%s' % (username, password)).replace('\n', '')
|
||||
auth_s = base64('%s:%s' % (username, password))
|
||||
r.headers['Authorization'] = ('Basic %s' % auth_s)
|
||||
|
||||
return r
|
||||
|
||||
Reference in New Issue
Block a user