Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(768)

Unified Diff: remoting/client/appengine/api.py

Issue 7033042: Update the appengine code to use OAuth2 and break the gdata dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixed. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/client/appengine/auth.py » ('j') | remoting/client/appengine/auth.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/appengine/api.py
diff --git a/remoting/client/appengine/api.py b/remoting/client/appengine/api.py
index ec16fc63cd7f468e4506f78d0de956242ddb983d..babb923a799a1593280ac936dbdcd7617d024bf5 100644
--- a/remoting/client/appengine/api.py
+++ b/remoting/client/appengine/api.py
@@ -10,8 +10,7 @@ import logging
from django.utils import simplejson as json
-import gdata.client
-
+from google.appengine.api import urlfetch
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp.util import login_required
@@ -30,26 +29,21 @@ class GetXmppTokenHandler(webapp.RequestHandler):
self.response.out.write('User has not authenticated')
self.set_status(400)
+
class GetHostListHandler(webapp.RequestHandler):
"""Proxies the host-list handlers on the Chromoting directory."""
@login_required
def get(self):
- try:
- client = gdata.client.GDClient()
- host_list_json = client.Request(
- method='GET',
- uri="https://www.googleapis.com/chromoting/v1/@me/hosts",
- converter=None,
- desired_class=None,
- auth_token=auth.GetChromotingToken())
- self.response.headers['Content-Type'] = 'application/json'
- self.response.out.write(host_list_json.read())
- except auth.NotAuthenticated:
- self.response.out.write('User has not authenticated')
- self.response.set_status(400)
- except (gdata.client.Unauthorized, gdata.client.RequestError), inst:
- self.response.out.write(inst.reason)
- self.response.set_status(inst.status)
+ result = urlfetch.fetch(
+ url = 'https://www.googleapis.com/chromoting/v1/@me/hosts',
+ method = urlfetch.GET,
+ headers = {'Authorization': 'OAuth ' + auth.GetAccessToken()})
+ self.response.headers['Content-Type'] = 'application/json'
Jamie 2011/05/20 16:46:47 In the previous code, the content-type was only se
awong 2011/05/20 20:37:38 Good catch. Actually, I'm just relaying the full
+ self.response.out.write(result.content)
Jamie 2011/05/20 16:46:47 Does |write| write the data to the client immediat
awong 2011/05/20 20:37:38 I'm pretty sure it's not a streaming response. Bu
+ for i in result.headers:
+ self.response.headers[i] = result.headers[i]
+ self.response.set_status(result.status_code)
+
def main():
application = webapp.WSGIApplication(
« no previous file with comments | « no previous file | remoting/client/appengine/auth.py » ('j') | remoting/client/appengine/auth.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698