def unpack_token(token):
    """
    Unpack a JSON-serialized JWT or a compact-serialized JWT
    Returns (header, payload, signature, signing_input) on success
    Raises DecodeError on bad input
    """
    if isinstance(token, (unicode,str)):
        return _decode_token_compact(token)

    else:
        return _decode_token_json(token)