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

Unified Diff: third_party/oauth2client/appengine.py

Issue 1094533003: Revert of Upgrade 3rd packages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 8 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 | « third_party/oauth2client/anyjson.py ('k') | third_party/oauth2client/client.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/oauth2client/appengine.py
diff --git a/third_party/oauth2client/appengine.py b/third_party/oauth2client/appengine.py
index 4131513d1d1a498ec527b32c8c0c07fb8547acbc..5cd3f4bafb4b67218494d68cf734881273a61e94 100644
--- a/third_party/oauth2client/appengine.py
+++ b/third_party/oauth2client/appengine.py
@@ -1,4 +1,4 @@
-# Copyright 2014 Google Inc. All rights reserved.
+# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,14 +19,14 @@
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
+import base64
import cgi
-import json
+import httplib2
import logging
import os
import pickle
import threading
-
-import httplib2
+import time
from google.appengine.api import app_identity
from google.appengine.api import memcache
@@ -41,6 +41,7 @@
from oauth2client import clientsecrets
from oauth2client import util
from oauth2client import xsrfutil
+from oauth2client.anyjson import simplejson
from oauth2client.client import AccessTokenRefreshError
from oauth2client.client import AssertionCredentials
from oauth2client.client import Credentials
@@ -158,20 +159,15 @@
Args:
scope: string or iterable of strings, scope(s) of the credentials being
requested.
- **kwargs: optional keyword args, including:
- service_account_id: service account id of the application. If None or
- unspecified, the default service account for the app is used.
"""
self.scope = util.scopes_to_string(scope)
- self._kwargs = kwargs
- self.service_account_id = kwargs.get('service_account_id', None)
# 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):
- data = json.loads(json_data)
+ def from_json(cls, json):
+ data = simplejson.loads(json)
return AppAssertionCredentials(data['scope'])
def _refresh(self, http_request):
@@ -190,21 +186,10 @@
"""
try:
scopes = self.scope.split()
- (token, _) = app_identity.get_access_token(
- scopes, service_account_id=self.service_account_id)
- except app_identity.Error as e:
+ (token, _) = app_identity.get_access_token(scopes)
+ except app_identity.Error, e:
raise AccessTokenRefreshError(str(e))
self.access_token = token
-
- @property
- def serialization_data(self):
- raise NotImplementedError('Cannot serialize credentials for AppEngine.')
-
- def create_scoped_required(self):
- return not self.scope
-
- def create_scoped(self, scopes):
- return AppAssertionCredentials(scopes, **self._kwargs)
class FlowProperty(db.Property):
@@ -449,7 +434,6 @@
entity_key = db.Key.from_path(self._model.kind(), self._key_name)
db.delete(entity_key)
- @db.non_transactional(allow_existing=True)
def locked_get(self):
"""Retrieve Credential from datastore.
@@ -472,7 +456,6 @@
credentials.set_store(self)
return credentials
- @db.non_transactional(allow_existing=True)
def locked_put(self, credentials):
"""Write a Credentials to the datastore.
@@ -485,7 +468,6 @@
if self._cache:
self._cache.set(self._key_name, credentials.to_json())
- @db.non_transactional(allow_existing=True)
def locked_delete(self):
"""Delete Credential from datastore."""
@@ -571,14 +553,16 @@
Instantiate and then use with oauth_required or oauth_aware
as decorators on webapp.RequestHandler methods.
- ::
+ Example:
decorator = OAuth2Decorator(
client_id='837...ent.com',
client_secret='Qh...wwI',
scope='https://www.googleapis.com/auth/plus')
+
class MainHandler(webapp.RequestHandler):
+
@decorator.oauth_required
def get(self):
http = decorator.http()
@@ -666,9 +650,8 @@
provided to this constructor. A string indicating the name of the field
on the _credentials_class where a Credentials object will be stored.
Defaults to 'credentials'.
- **kwargs: dict, Keyword arguments are passed along as kwargs to
- the OAuth2WebServerFlow constructor.
-
+ **kwargs: dict, Keyword arguments are be passed along as kwargs to the
+ OAuth2WebServerFlow constructor.
"""
self._tls = threading.local()
self.flow = None
@@ -815,18 +798,14 @@
url = self.flow.step1_get_authorize_url()
return str(url)
- def http(self, *args, **kwargs):
+ def http(self):
"""Returns an authorized http instance.
Must only be called from within an @oauth_required decorated method, or
from within an @oauth_aware decorated method where has_credentials()
returns True.
-
- Args:
- *args: Positional arguments passed to httplib2.Http constructor.
- **kwargs: Positional arguments passed to httplib2.Http constructor.
- """
- return self.credentials.authorize(httplib2.Http(*args, **kwargs))
+ """
+ return self.credentials.authorize(httplib2.Http())
@property
def callback_path(self):
@@ -845,8 +824,7 @@
def callback_handler(self):
"""RequestHandler for the OAuth 2.0 redirect callback.
- Usage::
-
+ Usage:
app = webapp.WSGIApplication([
('/index', MyIndexHandler),
...,
@@ -880,7 +858,7 @@
user)
if decorator._token_response_param and credentials.token_response:
- resp_json = json.dumps(credentials.token_response)
+ resp_json = simplejson.dumps(credentials.token_response)
redirect_uri = util._add_query_parameter(
redirect_uri, decorator._token_response_param, resp_json)
@@ -909,23 +887,24 @@
Uses a clientsecrets file as the source for all the information when
constructing an OAuth2Decorator.
- ::
+ Example:
decorator = OAuth2DecoratorFromClientSecrets(
os.path.join(os.path.dirname(__file__), 'client_secrets.json')
scope='https://www.googleapis.com/auth/plus')
+
class MainHandler(webapp.RequestHandler):
+
@decorator.oauth_required
def get(self):
http = decorator.http()
# http is authorized with the user's Credentials and can be used
# in API calls
-
"""
@util.positional(3)
- def __init__(self, filename, scope, message=None, cache=None, **kwargs):
+ def __init__(self, filename, scope, message=None, cache=None):
"""Constructor
Args:
@@ -938,20 +917,17 @@
decorator.
cache: An optional cache service client that implements get() and set()
methods. See clientsecrets.loadfile() for details.
- **kwargs: dict, Keyword arguments are passed along as kwargs to
- the OAuth2WebServerFlow constructor.
"""
client_type, client_info = clientsecrets.loadfile(filename, cache=cache)
if client_type not in [
clientsecrets.TYPE_WEB, clientsecrets.TYPE_INSTALLED]:
raise InvalidClientSecretsError(
- "OAuth2Decorator doesn't support this OAuth 2.0 flow.")
- constructor_kwargs = dict(kwargs)
- constructor_kwargs.update({
- 'auth_uri': client_info['auth_uri'],
- 'token_uri': client_info['token_uri'],
- 'message': message,
- })
+ 'OAuth2Decorator doesn\'t support this OAuth 2.0 flow.')
+ constructor_kwargs = {
+ 'auth_uri': client_info['auth_uri'],
+ 'token_uri': client_info['token_uri'],
+ 'message': message,
+ }
revoke_uri = client_info.get('revoke_uri')
if revoke_uri is not None:
constructor_kwargs['revoke_uri'] = revoke_uri
@@ -984,4 +960,4 @@
"""
return OAuth2DecoratorFromClientSecrets(filename, scope,
- message=message, cache=cache)
+ message=message, cache=cache)
« no previous file with comments | « third_party/oauth2client/anyjson.py ('k') | third_party/oauth2client/client.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698