Pycharm Firebase Authentication library Install
已回答
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'
请先登录再写评论。
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.
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
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.