From f3b1b991e5a6c5ba16720a967c90a225dddcdd56 Mon Sep 17 00:00:00 2001 From: mg Date: Wed, 11 Sep 2019 19:28:54 -0300 Subject: [PATCH] Adding dependencies and retrieving account info. --- thrimshim/setup.py | 4 +++- thrimshim/thrimshim/main.py | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/thrimshim/setup.py b/thrimshim/setup.py index a3f14c4..5a5d8e5 100644 --- a/thrimshim/setup.py +++ b/thrimshim/setup.py @@ -10,7 +10,9 @@ setup( "gevent", "psycogreen", "psycopg2", - "google-auth" + "requests", + "six", + "google-auth", "wubloader-common", ], ) diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index bd5857a..9566050 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -42,15 +42,17 @@ def cors(app): @request_stats def auth_test(): if flask.request.method == 'POST': - userToken = flask.request.json.token + userToken = flask.request.json['token'] try: # Alternate method, query this endpoint: https://oauth2.googleapis.com/tokeninfo?id_token=XYZ123 idinfo = id_token.verify_oauth2_token(userToken, requests.Request(), None) # ID token is valid. Get the user's Google Account ID from the decoded token. - userid = idinfo['sub'] + # userid = idinfo['sub'] - return json.dumps(idinfo) + userEmail = idinfo['email'] + + return json.dumps(userEmail) except ValueError: # Invalid token pass