当前位置: 首页>>代码示例>>Python>>正文


Python Credentials.new_from_json方法代码示例

本文整理汇总了Python中client.Credentials.new_from_json方法的典型用法代码示例。如果您正苦于以下问题:Python Credentials.new_from_json方法的具体用法?Python Credentials.new_from_json怎么用?Python Credentials.new_from_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在client.Credentials的用法示例。


在下文中一共展示了Credentials.new_from_json方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: locked_get

# 需要导入模块: from client import Credentials [as 别名]
# 或者: from client.Credentials import new_from_json [as 别名]
  def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials

    Raises:
      CredentialsFileSymbolicLinkError if the file is a symbolic link.
    """
    credentials = None
    self._validate_file()
    try:
      f = open(self._filename, 'rb')
      content = f.read()
      f.close()
    except IOError:
      return credentials

    try:
      credentials = Credentials.new_from_json(content)
      credentials.set_store(self)
    except ValueError:
      pass

    return credentials
开发者ID:000pyo,项目名称:chrome-app-samples,代码行数:27,代码来源:file.py

示例2: locked_get

# 需要导入模块: from client import Credentials [as 别名]
# 或者: from client.Credentials import new_from_json [as 别名]
  def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    try:
      f = open(self._filename, 'r')
      content = f.read()
      f.close()
    except IOError:
      return credentials

    # First try reading as JSON, and if that fails fall back to pickle.
    try:
      credentials = Credentials.new_from_json(content)
      credentials.set_store(self)
    except ValueError:
      # TODO(jcgregorio) On a future release remove this path to finally remove
      # all pickle support.
      try:
        credentials = pickle.loads(content)
        credentials.set_store(self)
      except:
        pass

    return credentials
开发者ID:Isshun,项目名称:dart-samples,代码行数:30,代码来源:file.py

示例3: make_value_from_datastore

# 需要导入模块: from client import Credentials [as 别名]
# 或者: from client.Credentials import new_from_json [as 别名]
 def make_value_from_datastore(self, value):
   if value is None:
     return None
   if len(value) == 0:
     return None
   try:
     credentials = Credentials.new_from_json(value)
   except ValueError:
     credentials = None
   return credentials
开发者ID:zuoang,项目名称:g2fts,代码行数:12,代码来源:appengine.py

示例4: make_value_from_datastore

# 需要导入模块: from client import Credentials [as 别名]
# 或者: from client.Credentials import new_from_json [as 别名]
 def make_value_from_datastore(self, value):
   logging.info("make: Got type " + str(type(value)))
   if value is None:
     return None
   if len(value) == 0:
     return None
   try:
     credentials = Credentials.new_from_json(value)
   except ValueError:
     credentials = None
   return credentials
开发者ID:valentinalexeev,项目名称:vanewswatch,代码行数:13,代码来源:appengine.py

示例5: locked_get

# 需要导入模块: from client import Credentials [as 别名]
# 或者: from client.Credentials import new_from_json [as 别名]
  def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    content = keyring.get_password(self._service_name, self._user_name)

    if content is not None:
      try:
        credentials = Credentials.new_from_json(content)
        credentials.set_store(self)
      except ValueError:
        pass

    return credentials
开发者ID:YoSoyVladman,项目名称:contentbox,代码行数:19,代码来源:keyring_storage.py

示例6: _decode_credential_from_json

# 需要导入模块: from client import Credentials [as 别名]
# 或者: from client.Credentials import new_from_json [as 别名]
  def _decode_credential_from_json(self, cred_entry):
    """Load a credential from our JSON serialization.

    Args:
      cred_entry: A dict entry from the data member of our format

    Returns:
      (key, cred) where the key is the key tuple and the cred is the
        OAuth2Credential object.
    """
    raw_key = cred_entry['key']
    client_id = raw_key['clientId']
    user_agent = raw_key['userAgent']
    scope = raw_key['scope']
    key = (client_id, user_agent, scope)
    credential = None
    credential = Credentials.new_from_json(simplejson.dumps(cred_entry['credential']))
    return (key, credential)
开发者ID:pedia,项目名称:svfs,代码行数:20,代码来源:multistore_file.py

示例7: locked_get

# 需要导入模块: from client import Credentials [as 别名]
# 或者: from client.Credentials import new_from_json [as 别名]
  def locked_get(self):
    """Retrieve Credential from datastore.

    Returns:
      oauth2client.Credentials
    """
    if self._cache:
      json = self._cache.get(self._key_name)
      if json:
        return Credentials.new_from_json(json)
    entity = self._model.get_or_insert(self._key_name)
    credential = getattr(entity, self._property_name)
    if credential and hasattr(credential, 'set_store'):
      credential.set_store(self)
      if self._cache:
        self._cache.set(self._key_name, credentials.to_json())

    return credential
开发者ID:Isshun,项目名称:dart-samples,代码行数:20,代码来源:appengine.py

示例8: locked_get

# 需要导入模块: from client import Credentials [as 别名]
# 或者: from client.Credentials import new_from_json [as 别名]
  def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    try:
      f = open(self._filename, 'r')
      content = f.read()
      f.close()
    except IOError:
      return credentials

    try:
      credentials = Credentials.new_from_json(content)
      credentials.set_store(self)
    except ValueError:
      pass

    return credentials
开发者ID:pedia,项目名称:svfs,代码行数:23,代码来源:file.py


注:本文中的client.Credentials.new_from_json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。