(401) Unauthorized with python-firebase

2,211 views
Skip to first unread message

ultra909

unread,
Sep 29, 2015, 10:16:56 AM9/29/15
to Firebase Google Group
I am trying to update Firebase using the python-firebase library, but cannot get authentication to work, using some slightly adapted sample code:

from firebase import firebase as fb
auth
= fb.FirebaseAuthentication('<firebase secret>', 'm...@gmail.com', auth_payload={'uid': '<uid>'}) // NB renamed extras -> auth_payload, id -> uid here
firebase
= fb.FirebaseApplication('https://<url>.firebaseio.com', authentication=auth)
result
= firebase.get('/users', name=None, connection=None, params={'print': 'pretty'}) // HTTPError: 401 Client Error: Unauthorized
print result

I keep getting (401) Unauthorized, but I notice that the token generated by the library is radically different to one generated by a JavaScript version of FirebaseTokenGenerator - and the latter authenticates fine when I provide the same URL, uid and secret.


I noticed a GitHub issue, questioning why the library did not just use the official Python firebase-token-generator, so I forked and implemented the suggested change just in case it would make a difference, but still get the same result.


Can anyone suggest what might be tripping me up here? Possible my Python crypto libraries setup is somehow incompatible (I am using Anaconda)?



************************************************************************
Cross-post from StackOverflow.
************************************************************************

Jacob Wenger

unread,
Sep 29, 2015, 12:12:06 PM9/29/15
to fireba...@googlegroups.com
Hey there,

I responded on your Stack Overflow post. Let's keep the discussion there for simplicity.

Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/10cc3ba1-0ee3-45d9-b6b3-558164bb44b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcio Valenzuela

unread,
Sep 28, 2016, 10:37:18 AM9/28/16
to Firebase Google Group
Hi Jacob,

I looked at the so post but I dont understand your answer.  Im trying to authenticate a user as well so that I can fetch my data.  I dont know what the difference between these 2 methods that I found on the web is:

method A
auth = fb.FirebaseAuthentication('pwd', 'email', auth_payload="None")
firebase = fb.FirebaseApplication('https://stapp-48d1b.firebaseio.com', authentication=auth)

method B
def auth_with_password(self, email, password):
request_ref = 'https://auth.firebase.com/auth/firebase?firebase={0}&email={1}&password={2}'.\
format(self.fire_base_name, email, password)
request_object = self.requests.get(request_ref)
return request_object.json()

Please illustrate?  Thanks

Jacob Wenger

unread,
Sep 28, 2016, 4:29:18 PM9/28/16
to fireba...@googlegroups.com
The python-firebase library is not an official Firebase SDK. It is a third-party SDK which has not been updated since November of 2014. I would strongly urge you to either use the official REST API (API reference here and here) or a third-party SDK which is up-to-date like Pyrebase.

Cheers,
Jacob

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages