import base64
import json


def decode_credentials(auth_string):
    """
    Helper function to decode a base64-encoded response from the access token
    generator, into your client_id and access_token.

    You can get an access token via
    <https://www.rayleighconnect.net/oauth2/authorize?client_id=uob&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=token>.
    The response you get from the access token generator will be a
    base64-encoded string, which you can decode using this function.

    Parameters
    ----------
    auth_string : str
        The base64-encoded response from the access token generator.

    Returns
    -------
    client_id : str access_token : str

    Usage
    -----
    >>> client_id, access_token = decode_credentials("tdnTD35 ... bF46F60=")
    """
    credentials = base64.b64decode(auth_string)
    credentials = json.loads(credentials)
    return credentials["client_id"], credentials["access_token"]