Skip to content

Instantly share code, notes, and snippets.

@hiranya911
Created February 25, 2018 20:39
Show Gist options
  • Save hiranya911/2bc99d2b42365bf04c936a1e2ebdf558 to your computer and use it in GitHub Desktop.
Save hiranya911/2bc99d2b42365bf04c936a1e2ebdf558 to your computer and use it in GitHub Desktop.
from firebase_admin import auth
import flask
app = flask.Flask(__name__)
@app.route('/api')
def backend_operation():
id_token = flask.request.headers['X-Firebase-ID-Token']
try:
# Check if the ID token is valid. Additionally, check if it was issued
# before the user's refresh tokens were revoked.
auth.verify_id_token(id_token, check_revoked=True)
except auth.AuthError as error:
return flask.jsonify({'error': str(error)}), 401
return _do_operation(flask.requst)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment