|
31 | 31 | ssl_cert = key_data["ssl_certificate"]
|
32 | 32 | private_key = key_data["private_key"]
|
33 | 33 | client_key = key_data["client_key"]
|
| 34 | +client_id = key_data["client_id"] |
34 | 35 | hack_client_key = key_data["ios_client_key"]
|
35 | 36 |
|
36 | 37 | BaseRequest.MEMFILE_MAX = 1024 * 1024 * 1024 # Allow the request size to be 1G
|
@@ -355,24 +356,21 @@ def after_request():
|
355 | 356 | def verifyUserToken(token):
|
356 | 357 | # attempt to validate token on the client-side
|
357 | 358 | try:
|
358 |
| - tokenFields = verify_id_token(id_token, client_key) |
| 359 | + tokenFields = verify_id_token(id_token, client_id) |
359 | 360 | except AppIdentityError:
|
360 | 361 | try:
|
361 | 362 | tokenFields = verify_id_token(id_token, hack_client_key)
|
362 | 363 | 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) |
364 | 368 |
|
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) |
372 | 369 | in_client_key = tokenFields['audience']
|
373 | 370 | if (in_client_key != client_key):
|
374 | 371 | if (in_client_key != hack_client_key):
|
375 | 372 | abort(401, "Invalid client key %s" % in_client_key)
|
| 373 | + |
376 | 374 | logging.debug("Found user email %s" % tokenFields['email'])
|
377 | 375 | return tokenFields['email']
|
378 | 376 |
|
|
0 commit comments