Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Commit

Permalink
More @properties removed for older python support
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncadman committed Dec 1, 2012
1 parent 92ee52d commit 2a82cc7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion oauth2client/appengine.py
Expand Up @@ -78,11 +78,12 @@ def __init__(self, scope, **kwargs):
None,
None)

@classmethod
def from_json(cls, json):
data = simplejson.loads(json)
return AppAssertionCredentials(data['scope'])

from_json = classmethod(from_json)

def _refresh(self, http_request):
"""Refreshes the access_token.
Expand Down
16 changes: 9 additions & 7 deletions oauth2client/client.py
Expand Up @@ -177,7 +177,6 @@ def to_json(self):
"""
return self._to_json(Credentials.NON_SERIALIZED_MEMBERS)

@classmethod
def new_from_json(cls, s):
"""Utility class method to instantiate a Credentials subclass from a JSON
representation produced by to_json().
Expand All @@ -204,7 +203,8 @@ def new_from_json(cls, s):
from_json = getattr(kls, 'from_json')
return from_json(s)

@classmethod
new_from_json = classmethod(new_from_json)

def from_json(cls, s):
"""Instantiate a Credentials object from a JSON description of it.
Expand All @@ -218,6 +218,8 @@ def from_json(cls, s):
"""
return Credentials()

from_json = classmethod(from_json)


class Flow(object):
"""Base class for all Flow objects."""
Expand Down Expand Up @@ -453,7 +455,6 @@ def apply(self, headers):
def to_json(self):
return self._to_json(Credentials.NON_SERIALIZED_MEMBERS)

@classmethod
def from_json(cls, s):
"""Instantiate a Credentials object from a JSON description of it. The JSON
should have been produced by calling .to_json() on the object.
Expand Down Expand Up @@ -483,8 +484,9 @@ def from_json(cls, s):
data.get('id_token', None))
retval.invalid = data['invalid']
return retval

from_json = classmethod(from_json)

@property
def access_token_expired(self):
"""True if the credential is expired or invalid.
Expand All @@ -502,6 +504,7 @@ def access_token_expired(self):
now, self.token_expiry)
return True
return False
access_token_expired = property(access_token_expired)

def set_store(self, store):
"""Set the Storage for the credential.
Expand Down Expand Up @@ -673,14 +676,13 @@ def __init__(self, access_token, user_agent):
None,
user_agent)


@classmethod
def from_json(cls, s):
data = simplejson.loads(s)
retval = AccessTokenCredentials(
data['access_token'],
data['user_agent'])
return retval
from_json = classmethod(from_json)

def _refresh(self, http_request):
raise AccessTokenCredentialsError(
Expand Down Expand Up @@ -789,7 +791,6 @@ def __init__(self,
self.service_account_name = service_account_name
self.kwargs = kwargs

@classmethod
def from_json(cls, s):
data = simplejson.loads(s)
retval = SignedJwtAssertionCredentials(
Expand All @@ -803,6 +804,7 @@ def from_json(cls, s):
)
retval.invalid = data['invalid']
return retval
from_json = classmethod(from_json)

def _generate_assertion(self):
"""Generate the assertion that will be used in the request."""
Expand Down
4 changes: 2 additions & 2 deletions oauth2client/crypt.py
Expand Up @@ -60,7 +60,6 @@ def verify(self, message, signature):
except:
return False

@staticmethod
def from_string(key_pem, is_x509_cert):
"""Construct a Verified instance from a string.
Expand All @@ -80,6 +79,7 @@ def from_string(key_pem, is_x509_cert):
else:
pubkey = crypto.load_privatekey(crypto.FILETYPE_PEM, key_pem)
return Verifier(pubkey)
from_string = staticmethod(from_string)


class Signer(object):
Expand All @@ -104,7 +104,6 @@ def sign(self, message):
"""
return crypto.sign(self._key, message, 'sha256')

@staticmethod
def from_string(key, password='notasecret'):
"""Construct a Signer instance from a string.
Expand All @@ -120,6 +119,7 @@ def from_string(key, password='notasecret'):
"""
pkey = crypto.load_pkcs12(key, password).get_privatekey()
return Signer(pkey)
from_string = staticmethod(from_string)


def _urlsafe_b64encode(raw_bytes):
Expand Down

0 comments on commit 2a82cc7

Please sign in to comment.