本文介绍了如何修复Firebase_Admin错误TypeError:__init __()获得了意外的关键字参数'status'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Firebase的新手,并且正在在线关注其教程.我正在尝试向使用一些记录创建的快速数据库进行身份验证.我收到错误消息:TypeError: init ()获得了意外的关键字参数'status'

I'm new to Firebase and I am following their tutorial online. I'm trying to authenticate into a quick DB that I created with a few records. I'm getting the error: TypeError: init() got an unexpected keyword argument 'status'

我确保urllib3是最新的,并确认firebase_Admin是最新的.我检查了json文件的文件路径,并将数据库URL复制到其中.

I've made sure my urllib3 is up to date and confirmed my firebase_Admin is up to date. I've checked my file path for json file and copied my database URL into it.

import firebase_admin
from firebase_admin import credentials
from firebase_admin import db

#Generated from settings of a project.
cred = credentials.Certificate(r"Path to json file in the same directory as program")

firebase_admin.initialize_app(cred, {'databaseURL': 'https://mydatabase_from_firebase/'} )

我期望返回0,确认它可以正常工作,但我在下面得到了错误结果:

I am expecting for a return of 0, confirming it worked, but instead I am getting the error results below:

TypeError: __init__() got an unexpected keyword argument 'status'


完整回溯是:


Full traceback is:

推荐答案

这是由于urllib3包过时引起的.我使用以下解决方案解决了该错误.您也可以尝试.

This is caused due to the outdated urllib3 package.I resolved this error with the following solution. You can try it as well.

转到此文件(从给出的错误中获取该文件)-> C:\ Users \ Gaming \ Firbase_setup \ venv \ lib \ site-packages \ firebase_admin_http_client.py

Go to this file(Got this from the error you have given) -> C:\Users\Gaming\Firbase_setup\venv\lib\site-packages\firebase_admin_http_client.py

在firebase_admin_http_client.py中注释以下几行:

Comment the following lines from firebase_admin_http_client.py:

    #from requests.packages.urllib3.util import retry
    #DEFAULT_RETRY_CONFIG = retry.Retry(
    #connect=1, read=1, status=4, status_forcelist=[500, 503],
    #raise_on_status=False, backoff_factor=0.5)

还要在同一文件中如下更改 init 参数:

Also change the init parameter as below in the same file:

def __init__(
        self, credential=None, session=None, base_url='', headers=None,
        retries=1):

这篇关于如何修复Firebase_Admin错误TypeError:__init __()获得了意外的关键字参数'status'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 18:54