Skip to content

Commit 32c6547

Browse files
author
Jon Wayne Parrott
authored
Update firebase sample to use google-auth (#665)
1 parent ece73df commit 32c6547

File tree

10 files changed

+27
-322
lines changed

10 files changed

+27
-322
lines changed

appengine/standard/bigquery/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import os
2626

2727
from googleapiclient.discovery import build
28-
from oauth2client.appengine import OAuth2DecoratorFromClientSecrets
28+
from oauth2client.contrib.appengine import OAuth2DecoratorFromClientSecrets
2929
import webapp2
3030

3131

appengine/standard/firebase/firenotes/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ this sample.
2525
1. Within a virtualenv, install the dependencies to the backend service:
2626

2727
pip install -r requirements.txt -t lib
28-
pip install pycrypto
29-
30-
Although the pycrypto library is built in to the App Engine standard
31-
environment, it will not be bundled until deployment since it is
32-
platform-dependent. Thus, the app.yaml file includes the bundled version of
33-
pycrypto at runtime, but you still need to install it manually to run the
34-
application on the App Engine local development server.
3528

3629
1. [Add Firebase to your app.](https://firebase.google.com/docs/web/setup#add_firebase_to_your_app)
3730
1. Add your Firebase project ID to the backend’s `app.yaml` file as an

appengine/standard/firebase/firenotes/backend/app.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ handlers:
77
- url: /.*
88
script: main.app
99

10-
libraries:
11-
- name: ssl
12-
version: 2.7.11
13-
- name: pycrypto
14-
version: 2.6
15-
1610
env_variables:
1711
# Replace with your Firebase project ID.
1812
FIREBASE_PROJECT_ID: '<PROJECT_ID>'

appengine/standard/firebase/firenotes/backend/firebase_helper.py

Lines changed: 0 additions & 123 deletions
This file was deleted.

appengine/standard/firebase/firenotes/backend/firebase_helper_test.py

Lines changed: 0 additions & 176 deletions
This file was deleted.

appengine/standard/firebase/firenotes/backend/main.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
from flask import Flask, jsonify, request
1919
import flask_cors
2020
from google.appengine.ext import ndb
21+
import google.auth.transport.requests
22+
import google.oauth2.id_token
23+
import requests_toolbelt.adapters.appengine
2124

22-
import firebase_helper
23-
25+
# Use the App Engine Requests adapter. This makes sure that Requests uses
26+
# URLFetch.
27+
requests_toolbelt.adapters.appengine.monkeypatch()
28+
HTTP_REQUEST = google.auth.transport.requests.Request()
2429

2530
app = Flask(__name__)
2631
flask_cors.CORS(app)
@@ -68,7 +73,9 @@ def list_notes():
6873
"""Returns a list of notes added by the current Firebase user."""
6974

7075
# Verify Firebase auth.
71-
claims = firebase_helper.verify_auth_token(request)
76+
id_token = request.headers['Authorization'].split(' ').pop()
77+
claims = google.oauth2.id_token.verify_firebase_token(
78+
id_token, HTTP_REQUEST)
7279
if not claims:
7380
return 'Unauthorized', 401
7481

@@ -90,7 +97,9 @@ def add_note():
9097
"""
9198

9299
# Verify Firebase auth.
93-
claims = firebase_helper.verify_auth_token(request)
100+
id_token = request.headers['Authorization'].split(' ').pop()
101+
claims = google.oauth2.id_token.verify_firebase_token(
102+
id_token, HTTP_REQUEST)
94103
if not claims:
95104
return 'Unauthorized', 401
96105

0 commit comments

Comments
 (0)