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

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: remove the hardcoded localhost 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/app.yaml » ('j') | no next file with comments »
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..e1e2ddb758e8908df177961814a9575794632065 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,26 @@ 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())
+ if not auth.HasOAuth2Tokens():
+ self.response.set_status(403)
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)
+ self.response.out.write(
+ '{"error": { "code": -1, "message": "No OAuth2 token" }}')
+ return
+ result = urlfetch.fetch(
+ url = 'https://www.googleapis.com/chromoting/v1/@me/hosts',
+ method = urlfetch.GET,
+ headers = {'Authorization': 'OAuth ' + auth.GetAccessToken()})
+ self.response.set_status(result.status_code)
+ for i in result.headers:
+ self.response.headers[i] = result.headers[i]
+ self.response.out.write(result.content)
+
def main():
application = webapp.WSGIApplication(
« no previous file with comments | « no previous file | remoting/client/appengine/app.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698