| Index: appengine/chromium_build_logs/third_party/oauth2client/gce.py
|
| diff --git a/appengine/chromium_rietveld/third_party/oauth2client/gce.py b/appengine/chromium_build_logs/third_party/oauth2client/gce.py
|
| similarity index 77%
|
| copy from appengine/chromium_rietveld/third_party/oauth2client/gce.py
|
| copy to appengine/chromium_build_logs/third_party/oauth2client/gce.py
|
| index c7fd7c18a9b20bdbce80389e57a217861c0e54f3..fc3bd77bd9a3b86e39c68c7ac2a9361b38d9a5df 100644
|
| --- a/appengine/chromium_rietveld/third_party/oauth2client/gce.py
|
| +++ b/appengine/chromium_build_logs/third_party/oauth2client/gce.py
|
| @@ -1,4 +1,4 @@
|
| -# Copyright (C) 2012 Google Inc.
|
| +# Copyright 2014 Google Inc. All rights reserved.
|
| #
|
| # Licensed under the Apache License, Version 2.0 (the "License");
|
| # you may not use this file except in compliance with the License.
|
| @@ -19,12 +19,11 @@ Utilities for making it easier to use OAuth 2.0 on Google Compute Engine.
|
|
|
| __author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
|
|
| -import httplib2
|
| +import json
|
| import logging
|
| -import uritemplate
|
| +from six.moves import urllib
|
|
|
| from oauth2client import util
|
| -from oauth2client.anyjson import simplejson
|
| from oauth2client.client import AccessTokenRefreshError
|
| from oauth2client.client import AssertionCredentials
|
|
|
| @@ -57,13 +56,14 @@ class AppAssertionCredentials(AssertionCredentials):
|
| requested.
|
| """
|
| self.scope = util.scopes_to_string(scope)
|
| + self.kwargs = kwargs
|
|
|
| # Assertion type is no longer used, but still in the parent class signature.
|
| super(AppAssertionCredentials, self).__init__(None)
|
|
|
| @classmethod
|
| - def from_json(cls, json):
|
| - data = simplejson.loads(json)
|
| + def from_json(cls, json_data):
|
| + data = json.loads(json_data)
|
| return AppAssertionCredentials(data['scope'])
|
|
|
| def _refresh(self, http_request):
|
| @@ -78,13 +78,28 @@ class AppAssertionCredentials(AssertionCredentials):
|
| Raises:
|
| AccessTokenRefreshError: When the refresh fails.
|
| """
|
| - uri = uritemplate.expand(META, {'scope': self.scope})
|
| + query = '?scope=%s' % urllib.parse.quote(self.scope, '')
|
| + uri = META.replace('{?scope}', query)
|
| response, content = http_request(uri)
|
| if response.status == 200:
|
| try:
|
| - d = simplejson.loads(content)
|
| - except StandardError, e:
|
| + d = json.loads(content)
|
| + except Exception as e:
|
| raise AccessTokenRefreshError(str(e))
|
| self.access_token = d['accessToken']
|
| else:
|
| + if response.status == 404:
|
| + content += (' This can occur if a VM was created'
|
| + ' with no service account or scopes.')
|
| raise AccessTokenRefreshError(content)
|
| +
|
| + @property
|
| + def serialization_data(self):
|
| + raise NotImplementedError(
|
| + 'Cannot serialize credentials for GCE service accounts.')
|
| +
|
| + def create_scoped_required(self):
|
| + return not self.scope
|
| +
|
| + def create_scoped(self, scopes):
|
| + return AppAssertionCredentials(scopes, **self.kwargs)
|
|
|