本文整理汇总了Python中oauth2client.Credentials方法的典型用法代码示例。如果您正苦于以下问题:Python oauth2client.Credentials方法的具体用法?Python oauth2client.Credentials怎么用?Python oauth2client.Credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oauth2client
的用法示例。
在下文中一共展示了oauth2client.Credentials方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: locked_put
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def locked_put(self, credentials, overwrite=False):
"""Write a Credentials to the datastore.
Args:
credentials: Credentials, the credentials to store.
overwrite: Boolean, indicates whether you would like these credentials to
overwrite any existing stored credentials.
"""
args = {self.key_name: self.key_value}
if overwrite:
entity, unused_is_new = self.model_class.objects.get_or_create(**args)
else:
entity = self.model_class(**args)
setattr(entity, self.property_name, credentials)
entity.save()
示例2: locked_put
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def locked_put(self, credentials, overwrite=False):
"""Write a Credentials to the Django datastore.
Args:
credentials: Credentials, the credentials to store.
overwrite: Boolean, indicates whether you would like these
credentials to overwrite any existing stored
credentials.
"""
args = {self.key_name: self.key_value}
if overwrite:
(entity,
unused_is_new) = self.model_class.objects.get_or_create(**args)
else:
entity = self.model_class(**args)
setattr(entity, self.property_name, credentials)
entity.save()
示例3: locked_get
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def locked_get(self):
"""Retrieve Credential from datastore.
Returns:
oauth2client.Credentials
"""
credentials = None
if self._cache:
json = self._cache.get(self._key_name)
if json:
credentials = client.Credentials.new_from_json(json)
if credentials is None:
entity = self._get_entity()
if entity is not None:
credentials = getattr(entity, self._property_name)
if self._cache:
self._cache.set(self._key_name, credentials.to_json())
if credentials and hasattr(credentials, 'set_store'):
credentials.set_store(self)
return credentials
示例4: to_python
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def to_python(self, value):
if value is None:
return None
if isinstance(value, oauth2client.client.Credentials):
return value
return pickle.loads(base64.b64decode(value))
示例5: locked_get
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def locked_get(self):
"""Retrieve Credential from datastore.
Returns:
oauth2client.Credentials
"""
credential = None
query = {self.key_name: self.key_value}
entities = self.model_class.objects.filter(**query)
if len(entities) > 0:
credential = getattr(entities[0], self.property_name)
if credential and hasattr(credential, 'set_store'):
credential.set_store(self)
return credential
示例6: locked_delete
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def locked_delete(self):
"""Delete Credentials from the datastore."""
query = {self.key_name: self.key_value}
entities = self.model_class.objects.filter(**query).delete()
示例7: locked_put
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def locked_put(self, credentials):
"""Write a Credentials to the datastore.
Args:
credentials: Credentials, the credentials to store.
"""
args = {self.key_name: self.key_value}
entity = self.model_class(**args)
setattr(entity, self.property_name, credentials)
entity.save()
示例8: to_python
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def to_python(self, value):
if value is None:
return None
if isinstance(value, oauth2client.client.Credentials):
return value
return pickle.loads(base64.b64decode(smart_bytes(value)))
示例9: locked_get
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def locked_get(self):
"""Retrieve stored credential.
Returns:
oauth2client.Credentials
"""
credential = None
query = {self.key_name: self.key_value}
entities = self.model_class.objects.filter(**query)
if len(entities) > 0:
credential = getattr(entities[0], self.property_name)
if credential and hasattr(credential, 'set_store'):
credential.set_store(self)
return credential
示例10: locked_delete
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def locked_delete(self):
"""Delete Credentials from the datastore."""
query = {self.key_name: self.key_value}
entities = self.model_class.objects.filter(**query).delete()
示例11: make_value_from_datastore
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def make_value_from_datastore(self, value):
logger.info("make: Got type " + str(type(value)))
if value is None:
return None
if len(value) == 0:
return None
try:
credentials = client.Credentials.new_from_json(value)
except ValueError:
credentials = None
return credentials
示例12: validate
# 需要导入模块: import oauth2client [as 别名]
# 或者: from oauth2client import Credentials [as 别名]
def validate(self, value):
value = super(CredentialsProperty, self).validate(value)
logger.info("validate: Got type " + str(type(value)))
if value is not None and not isinstance(value, client.Credentials):
raise db.BadValueError(
'Property {0} must be convertible '
'to a Credentials instance ({1})'.format(self.name, value))
return value