Skip to content

Instantly share code, notes, and snippets.

@dmattia
Created October 1, 2016 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmattia/8ca6d74db55bd88ca02d445feeed4f48 to your computer and use it in GitHub Desktop.
Save dmattia/8ca6d74db55bd88ca02d445feeed4f48 to your computer and use it in GitHub Desktop.
authenticate via token generator for firebase in python
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