Created
October 1, 2016 17:14
-
-
Save dmattia/8ca6d74db55bd88ca02d445feeed4f48 to your computer and use it in GitHub Desktop.
authenticate via token generator for firebase in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from firebase_token_generator import create_token | |
from firebase import Firebase | |
base_url = "https://sengo-fb3-prod.firebaseio.com/" | |
deal_url = base_url + 'deals' | |
active_deals_url = base_url + 'activeDeals/1/activeDeals' | |
future_deals_url = base_url + 'activeDeals/1/futureDeals' | |
inactive_deals_url = base_url + 'inactiveDeals/1/inactiveDeals' | |
# Create custom token | |
auth_payload = { "uid": "..." } | |
secret_key = "..." | |
options = { | |
"debug": True, | |
"admin": True | |
} | |
token = create_token(secret_key, auth_payload, options) | |
# Create references by adding the auth tokens to the respective urls | |
ref = Firebase(base_url, auth_token=token) | |
deal_ref = Firebase(deal_url, auth_token=token) | |
active_deals_ref = Firebase(active_deals_url, auth_token=token) | |
future_deals_ref = Firebase(future_deals_url, auth_token=token) | |
inactive_deals_ref = Firebase(inactive_deals_url, auth_token=token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment