import requests


def _get_access_token(key: str, secret: str) -> str:
    """
    Requests an access token from Bitbucket.

    :param key:
        The OAuth consumer key
    :param secret:
        The OAuth consumer secret
    :return:
        The Bitbucket access token
    """
    url = 'https://bitbucket.org/site/oauth2/access_token'

    data = {
        'grant_type': 'client_credentials'
    }

    response = requests.post(url, data, auth=(key, secret))

    if response.status_code != requests.codes.get('ok'):
        response.raise_for_status()

    return response.json()['access_token']