oauth/client.py
changeset 10 50b532f5e6cb
parent 5 4407b131a70e
child 32 eb9e83610c99
--- a/oauth/client.py	Wed Mar 02 12:12:44 2016 +0100
+++ b/oauth/client.py	Thu Mar 03 16:28:46 2016 +0100
@@ -33,8 +33,10 @@
     if 'me' not in session:
         resp = remote.get('user/InfoComplete')
         print("authcode resp data: "+str(resp.data))
-        me = resp.data.get("username", "")
+        me = resp.data.get("displayName", "")
         session["me"] = me
+        id = resp.data.get("id", "")
+        session["me_id"] = id
     if 'remote_oauth_clientcredentials' not in session:
         auth_string = bytes(app.config["CLIENT_ID"]+':'+app.config['CLIENT_SECRET'], "utf-8")
         auth_code = base64.b64encode(auth_string).decode("utf-8")
@@ -51,17 +53,17 @@
         print("clientcredentials resp data: "+str(resp.data))
         server = resp.data.get("username", "")
         session["server"] = server
-    return render_template('client/index.html', current_username=session["me"], oauth_username=session["server"])
+    return render_template('client/index.html', current_user_id=session["me_id"], current_username=session["me"], oauth_username=session["server"])
 
 @app.route('/renkan-request')
 def renkan_request():
     if 'remote_oauth_clientcredentials' in session:
         resp = requests.post(
-            app.config["CREATE_RENKAN_ENDPOINT"]+"?act_as="+session.get("me", "anonymous"), 
+            app.config["CREATE_RENKAN_ENDPOINT"]+"?act_as="+str(session.get("me_id", "anonymous")), 
             {"title": "RENKAN_FROM_GED"},
             headers={
                 'Authorization': 'Bearer %s' % session['remote_oauth_clientcredentials'][0],
-                'renkan-act-as': session.get("me", "anonymous")
+                'renkan-act-as': session.get("me_id", "anonymous")
             }
         )
         print(resp.text)