def base64url_decode(s):
    """
    Decodes a url-safe base64 encoded string.
    """

    if type(s) is unicode:
        s = s.encode("US-ASCII")

    if len(s) % 4 == 3:
        s += "="
    elif len(s) % 4 == 2:
        s += "=="

    # b64decode is real crap when checking for the validity of the input.
    try:
        return base64.b64decode(s, "-_")
    except:
        _, e, tb = sys.exc_info()
        raise exceptions.InvalidInputException(
            "Invalid base64 sequence: %s" % e), None, tb
dataset/ETHPy150Open spotify/crtauth/crtauth/ssh.py/base64url_decode/original