在 python Cloud Function 中使用 Firebase Admin 身份验证验证 id 令牌时,错误“HTTPResponse”对象没有属性“strict”

问题描述 投票:0回答:0

我在 python 3.9 中有一个调用此代码的云函数:

firebase_admin.initialize_app()


def check_token(token, app_check_token):
    """
    :param app_check_token:
    :param token:
    :return:
    """
    try:
        app_token = app_check.verify_token(app_check_token)
        logging.info(f"App check token verified : {app_token}")
    except Exception as e:
        logging.error(f"Exception while decoding app check token : {e}")
    try:
        decoded_token = auth.verify_id_token(token)
        logging.info(f"verified token : {decoded_token}")
        if "uid" in decoded_token:
            return decoded_token["uid"]
        return ""
    except Exception as e:
        logging.error(f"check_token : {e}")
        return ""

这是我使用有效的 firebase id 令牌调用我的函数时从 Cloud logging 获得的日志:

ERROR:root:check_token : 'HTTPResponse' object has no attribute 'strict'

请问这是什么意思?

注意:我有10个云函数,只有一个有这个问题,和其他的没有区别...

ChatGPT 说 Firebase 身份验证后端出错并联系 firbease 支持,但由于这只发生在我的一个云功能中,我想知道我是否做错了什么。

PS:如果我在本地运行这个云函数,一切都很好,

 functions-framework --target function_name --debug --port=8080
使用完全相同的代码。

python firebase firebase-authentication google-cloud-functions firebase-admin
© www.soinside.com 2019 - 2024. All rights reserved.