Skip to content

Commit 20a659b

Browse files
committed
made changes to cfc_webapp.py to use client_id for oath
1 parent edbe1a1 commit 20a659b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

CFC_WebApp/api/cfc_webapp.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
ssl_cert = key_data["ssl_certificate"]
3232
private_key = key_data["private_key"]
3333
client_key = key_data["client_key"]
34+
client_id = key_data["client_id"]
3435
hack_client_key = key_data["ios_client_key"]
3536

3637
BaseRequest.MEMFILE_MAX = 1024 * 1024 * 1024 # Allow the request size to be 1G
@@ -355,24 +356,21 @@ def after_request():
355356
def verifyUserToken(token):
356357
# attempt to validate token on the client-side
357358
try:
358-
tokenFields = verify_id_token(id_token, client_key)
359+
tokenFields = verify_id_token(id_token, client_id)
359360
except AppIdentityError:
360361
try:
361362
tokenFields = verify_id_token(id_token, hack_client_key)
362363
except AppIdentityError:
363-
pass
364+
# fall back to verifying using Google API
365+
constructedURL = ("https://www.googleapis.com/oauth2/v1/tokeninfo?id_token=%s" % token)
366+
r = requests.get(constructedURL)
367+
tokenFields = json.loads(r.content)
364368

365-
if tokenFields:
366-
return tokenFields['email']
367-
368-
# fall back to verifying using Google API
369-
constructedURL = ("https://www.googleapis.com/oauth2/v1/tokeninfo?id_token=%s" % token)
370-
r = requests.get(constructedURL)
371-
tokenFields = json.loads(r.content)
372369
in_client_key = tokenFields['audience']
373370
if (in_client_key != client_key):
374371
if (in_client_key != hack_client_key):
375372
abort(401, "Invalid client key %s" % in_client_key)
373+
376374
logging.debug("Found user email %s" % tokenFields['email'])
377375
return tokenFields['email']
378376

0 commit comments

Comments
 (0)