我在python3.9中有一个Cloud函数,它调用以下代码:

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获得的日志(log):

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

这是什么意思?

注:我有10个云函数,只有一个有这个问题,与其他没有区别…

ChatGPT说这是Firebase身份验证后端的错误,并联系Firbease支持人员,但由于这种情况只发生在我的一个Cloud函数中,我想知道我是否做错了什么.

PS:如果我在本地运行这个云函数,使用 functions-framework --target function_name --debug --port=8080和完全相同的代码,一切都很好.

推荐答案

我也有类似的问题,有人指给我看: https://github.com/psf/requests/issues/6437个 还特别针对Firebase: https://github.com/firebase/firebase-admin-python/issues/699

显然,这个库有了突破性的变化,一种解决方案是使用urllib3 2.0.0作为解决方案,我还没有try 过(不确定如何考虑到我依赖于Firebase).

You can see my question here: Firebase Authentication: 'HTTPResponse' object has no attribute 'strict', status: error

Python相关问答推荐

使用图片生成PDF Django rest框架

使用regex分析具有特定字符的字符串(如果它们存在)

更改Seaborn条形图中的x轴日期时间限制

DuckDB将蜂巢分区插入拼花文件

Python -Polars库中的滚动索引?

使用polars .滤镜进行切片速度比pandas .loc慢

当密钥是复合且唯一时,Pandas合并抱怨标签不唯一

@Property方法上的inspect.getmembers出现意外行为,引发异常

根据另一列中的nan重置值后重新加权Pandas列

Python上的Instagram API:缺少client_id参数"

修复mypy错误-赋值中的类型不兼容(表达式具有类型xxx,变量具有类型yyy)

使用密钥字典重新配置嵌套字典密钥名

python panda ExcelWriter切换动态公式到数组公式

python中csv. Dictreader. fieldname的类型是什么?'

Pandas—MultiIndex Resample—我不想丢失其他索引的信息´

如何将一组组合框重置回无 Select tkinter?

判断Python操作:如何从字面上得到所有decorator ?

使用Python TCP套接字发送整数并使用C#接收—接收正确数据时出错

使用SQLAlchemy从多线程Python应用程序在postgr中插入多行的最佳方法是什么?'

如果不使用. to_list()[0],我如何从一个pandas DataFrame中获取一个值?