10

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'

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/'} )

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:

Traceback (most recent call last): File "C:/Users/Gaming/Firbase_setup/test.py", line 3, in from firebase_admin import db File "C:\Users\Gaming\Firbase_setup\venv\lib\site-packages\firebase_admin\db.py", line 33, in from firebase_admin import _http_client File "C:\Users\Gaming\Firbase_setup\venv\lib\site-packages\firebase_admin_http_client.py", line 32, in raise_on_status=False, backoff_factor=0.5) TypeError: init() got an unexpected keyword argument 'status'

2
  • 1
    Can you post a full traceback?
    – knh190
    May 19, 2019 at 23:34
  • Full trace back. I'm using PyCharm if that helps. Traceback (most recent call last): File "C:/Users/Gaming/Firbase_setup/test.py", line 3, in <module> from firebase_admin import db File "C:\Users\Gaming\Firbase_setup\venv\lib\site-packages\firebase_admin\db.py", line 33, in <module> from firebase_admin import _http_client File "C:\Users\Gaming\Firbase_setup\venv\lib\site-packages\firebase_admin_http_client.py", line 32, in <module> raise_on_status=False, backoff_factor=0.5) TypeError: __init__() got an unexpected keyword argument 'status' May 20, 2019 at 0:37

4 Answers 4

18

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

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

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)

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

def __init__(
        self, credential=None, session=None, base_url='', headers=None,
        retries=1, timeout=300):
2
  • 2
    Awesome, that did work. Just to note for people for future reference, that file is in the Firebase_admin folder and it's called _http_client.py. Thanks again for your help. May 21, 2019 at 23:56
  • thanks for the solution, it indeed works. strange that they still didn't update this in 3 years
    – dorian
    Feb 28, 2022 at 11:43
15

Upgrading requests to current version 2.22.0 worked for me.

As the previous answer suggests, some libraries are outdated and can cause this issue.

3

uninstall the older version of requests

pip uninstall requests

and install the latest one

pip install requests
0

Some times i getting time out error so that to resolve that

Change init to below code

def __init__(
            self, credential=None, session=None, base_url='', headers=None,
            retries=DEFAULT_RETRY_CONFIG, timeout=DEFAULT_TIMEOUT_SECONDS):

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.