From a3793afda214260257868985e1996f54439948dc Mon Sep 17 00:00:00 2001 From: Ivan Date: Sat, 4 Jun 2016 22:31:54 -0500 Subject: [PATCH] Adding auth_token when creating a new instance When calling child or parent methods it will raise an exception if there exists an auth_token if you try to access to the content: HTTPError: 401 Client Error: Unauthorized --- firebase/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/firebase/__init__.py b/firebase/__init__.py index 81e94a6..b603e7d 100644 --- a/firebase/__init__.py +++ b/firebase/__init__.py @@ -17,7 +17,10 @@ def __init__(self, root_url, auth_token=None): def child(self, path): root_url = '%s/' % self.ROOT_URL url = urlparse.urljoin(root_url, path.lstrip('/')) - return Firebase(url) + if self.auth_token: + return Firebase(url, auth_token=self.auth_token) + else: + return Firebase(url) def parent(self): url = os.path.dirname(self.ROOT_URL) @@ -25,7 +28,10 @@ def parent(self): up = urlparse.urlparse(url) if up.path == '': return None #maybe throw exception here? - return Firebase(url) + if self.auth_token: + return Firebase(url, auth_token=self.auth_token) + else: + return Firebase(url) def name(self): return os.path.basename(self.ROOT_URL)