Pycharm Firebase Authentication library Install

Answered

I installed the firebase library through the interpreter dialog.  I even installed the python_token_generator library but I cannot find any firebase-authentication library and when I use the import:

from firebase import FirebaseAuthentication

it gets greyed out and when I optimize imports it gets erased but when I run the code that has:

authentication = firebase.Authentication('pwd', 'email', extra={'id': 123})

I get:

AttributeError: 'FirebaseApplication' object has no attribute 'Authentication'

3 comments
Comment actions Permalink

Yes, if you have that import and nothing uses it, Optimize Imports erases it. The gray means, nothing is using the import.

On the next line, you reference firebase.authentication but you've imported the symbol FirebaseAuthentication. According to the docs, the import should be:

from firebase import firebase
authentication = firebase.Authentication('THIS_IS_MY_SECRET', 'ozgurvt@gmail.com', extra={'id': 123})

I don't think this is a PyCharm issue. I think you just need to get the Python imports correct.




0
Comment actions Permalink
I am trying to use your github FireBase with Python. 
 
If read/write does not required authentication, everything works as expected.
 
However, when i try to use the same with authentication i always get:
       
"requests.exceptions.HTTPError: 400 Client Error: Bad Request"
 
I have looked in many places before writing to you, but could not find any information which could help me.
 
My Code:
 
authentication = FirebaseAuthentication('rhelfer@gmail.com', True, True, extra={'id': 'g23gg72g-2g1g-4gg4-8h9h-123123hh123h'})

firebase = FirebaseApplication('https://test.firebaseio.com', authentication)

 

user = authentication.get_user()

print user.firebase_auth_token

--> I get something which looks like it is a valid token 

result = firebase.get('/printThis', None, params={'print': 'pretty'}, headers={'X_FANCY_HEADER': 'very fancy'})

--> I get an error and the python script crash 

Traceback (most recent call last):

  File "recieptPrinter.py", line 26, in <module>

    result = firebase.get('/printThis', None, params={'print': 'pretty'}, headers={'X_FANCY_HEADER': 'very fancy'})

  File "/usr/local/lib/python2.7/dist-packages/firebase/decorators.py", line 19, in wrapped

    return f(*args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/firebase/firebase.py", line 274, in get

    return make_get_request(endpoint, params, headers, connection=connection)

  File "/usr/local/lib/python2.7/dist-packages/firebase/decorators.py", line 19, in wrapped

    return f(*args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/firebase/firebase.py", line 42, in make_get_request

    response.raise_for_status()

  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 825, in raise_for_status

    raise HTTPError(http_error_msg, response=self)

 

requests.exceptions.HTTPError: 400 Client Error: Bad Request

0
Comment actions Permalink

As a quick question, you say "the PyCharm github FireBase with Python". I might be wrong, but I'm not sure PyCharm produces a Firebase Python library. Most likely you are using a Firebase Python library produced by someone in the Python community. If so, your best bet is to file a ticket in that GitHub repo.

0

Please sign in to leave a comment.