aboutsummaryrefslogtreecommitdiff
path: root/oauth2client/contrib/appengine.py
diff options
context:
space:
mode:
Diffstat (limited to 'oauth2client/contrib/appengine.py')
-rw-r--r--oauth2client/contrib/appengine.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/oauth2client/contrib/appengine.py b/oauth2client/contrib/appengine.py
index c1326ee..661105e 100644
--- a/oauth2client/contrib/appengine.py
+++ b/oauth2client/contrib/appengine.py
@@ -29,13 +29,13 @@ from google.appengine.api import memcache
from google.appengine.api import users
from google.appengine.ext import db
from google.appengine.ext.webapp.util import login_required
+import httplib2
import webapp2 as webapp
import oauth2client
-from oauth2client import _helpers
from oauth2client import client
from oauth2client import clientsecrets
-from oauth2client import transport
+from oauth2client import util
from oauth2client.contrib import xsrfutil
# This is a temporary fix for a Google internal issue.
@@ -45,6 +45,8 @@ except ImportError: # pragma: NO COVER
_appengine_ndb = None
+__author__ = 'jcgregorio@google.com (Joe Gregorio)'
+
logger = logging.getLogger(__name__)
OAUTH2CLIENT_NAMESPACE = 'oauth2client#ns'
@@ -129,7 +131,7 @@ class AppAssertionCredentials(client.AssertionCredentials):
information to generate and refresh its own access tokens.
"""
- @_helpers.positional(2)
+ @util.positional(2)
def __init__(self, scope, **kwargs):
"""Constructor for AppAssertionCredentials
@@ -141,7 +143,7 @@ class AppAssertionCredentials(client.AssertionCredentials):
or unspecified, the default service account for
the app is used.
"""
- self.scope = _helpers.scopes_to_string(scope)
+ self.scope = util.scopes_to_string(scope)
self._kwargs = kwargs
self.service_account_id = kwargs.get('service_account_id', None)
self._service_account_email = None
@@ -155,15 +157,17 @@ class AppAssertionCredentials(client.AssertionCredentials):
data = json.loads(json_data)
return AppAssertionCredentials(data['scope'])
- def _refresh(self, http):
- """Refreshes the access token.
+ def _refresh(self, http_request):
+ """Refreshes the access_token.
Since the underlying App Engine app_identity implementation does its
own caching we can skip all the storage hoops and just to a refresh
using the API.
Args:
- http: unused HTTP object
+ http_request: callable, a callable that matches the method
+ signature of httplib2.Http.request, used to make the
+ refresh request.
Raises:
AccessTokenRefreshError: When the refresh fails.
@@ -301,7 +305,7 @@ class StorageByKeyName(client.Storage):
and that entities are stored by key_name.
"""
- @_helpers.positional(4)
+ @util.positional(4)
def __init__(self, model, key_name, property_name, cache=None, user=None):
"""Constructor for Storage.
@@ -519,7 +523,7 @@ class OAuth2Decorator(object):
flow = property(get_flow, set_flow)
- @_helpers.positional(4)
+ @util.positional(4)
def __init__(self, client_id, client_secret, scope,
auth_uri=oauth2client.GOOGLE_AUTH_URI,
token_uri=oauth2client.GOOGLE_TOKEN_URI,
@@ -586,7 +590,7 @@ class OAuth2Decorator(object):
self.credentials = None
self._client_id = client_id
self._client_secret = client_secret
- self._scope = _helpers.scopes_to_string(scope)
+ self._scope = util.scopes_to_string(scope)
self._auth_uri = auth_uri
self._token_uri = token_uri
self._revoke_uri = revoke_uri
@@ -738,8 +742,7 @@ class OAuth2Decorator(object):
*args: Positional arguments passed to httplib2.Http constructor.
**kwargs: Positional arguments passed to httplib2.Http constructor.
"""
- return self.credentials.authorize(
- transport.get_http_object(*args, **kwargs))
+ return self.credentials.authorize(httplib2.Http(*args, **kwargs))
@property
def callback_path(self):
@@ -801,7 +804,7 @@ class OAuth2Decorator(object):
if (decorator._token_response_param and
credentials.token_response):
resp_json = json.dumps(credentials.token_response)
- redirect_uri = _helpers._add_query_parameter(
+ redirect_uri = util._add_query_parameter(
redirect_uri, decorator._token_response_param,
resp_json)
@@ -845,7 +848,7 @@ class OAuth2DecoratorFromClientSecrets(OAuth2Decorator):
"""
- @_helpers.positional(3)
+ @util.positional(3)
def __init__(self, filename, scope, message=None, cache=None, **kwargs):
"""Constructor
@@ -888,7 +891,7 @@ class OAuth2DecoratorFromClientSecrets(OAuth2Decorator):
self._message = 'Please configure your application for OAuth 2.0.'
-@_helpers.positional(2)
+@util.positional(2)
def oauth2decorator_from_clientsecrets(filename, scope,
message=None, cache=None):
"""Creates an OAuth2Decorator populated from a clientsecrets file.