File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
appengine/flexible/endpoints Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 30
30
app = Flask (__name__ )
31
31
32
32
33
+ def _base64_decode (encoded_str ):
34
+ # Add paddings manually if necessary.
35
+ num_missed_paddings = 4 - len (encoded_str ) % 4
36
+ if num_missed_paddings != 4 :
37
+ encoded_str += b'=' * num_missed_paddings
38
+ return base64 .b64decode (encoded_str ).decode ('utf-8' )
39
+
40
+
33
41
@app .route ('/echo' , methods = ['POST' ])
34
42
def echo ():
35
43
"""Simple echo service."""
@@ -42,7 +50,7 @@ def auth_info():
42
50
encoded_info = request .headers .get ('X-Endpoint-API-UserInfo' , None )
43
51
44
52
if encoded_info :
45
- info_json = base64 . b64decode (encoded_info ). decode ( 'utf-8' )
53
+ info_json = _base64_decode (encoded_info )
46
54
user_info = json .loads (info_json )
47
55
else :
48
56
user_info = {'id' : 'anonymous' }
You can’t perform that action at this time.
0 commit comments