django_example_ynh/django_ynh/test_utils.py
2020-12-28 18:52:29 +01:00

8 lines
260 B
Python

import base64
def generate_basic_auth(username, password):
basic_auth = f'{username}:{password}'
basic_auth_creds = bytes(basic_auth, encoding='utf-8')
creds = str(base64.b64encode(basic_auth_creds), encoding='utf-8')
return f'basic {creds}'