~homeworkprod/byceps

ref: ee44f550bd6c9f49e72424cd5826669dd1f57c1c byceps/tests/integration/api/helpers.py -rw-r--r-- 489 bytes
ee44f550 — Jochen Kupperschmidt Avoid same German translation for different meanings of "cancel" 1 year, 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""
tests.api.helpers
~~~~~~~~~~~~~~~~~

:Copyright: 2006-2021 Jochen Kupperschmidt
:License: Revised BSD (see `LICENSE` file for details)
"""

from base64 import b64encode
from typing import Tuple


def assemble_authorization_header(api_token: str) -> Tuple[str, str]:
    """Assemble header to authorize against the API."""
    encoded_token = b64encode(api_token.encode('ascii')).decode('ascii')

    name = 'Authorization'
    value = 'Bearer ' + encoded_token

    return name, value