當前位置: 首頁>>代碼示例>>Python>>正文


Python client.Credentials類代碼示例

本文整理匯總了Python中client.Credentials的典型用法代碼示例。如果您正苦於以下問題:Python Credentials類的具體用法?Python Credentials怎麽用?Python Credentials使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Credentials類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: locked_get

  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,代碼行數:25,代碼來源:file.py

示例2: locked_get

  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,代碼行數:28,代碼來源:file.py

示例3: make_value_from_datastore

 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,代碼行數:10,代碼來源:appengine.py

示例4: make_value_from_datastore

 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,代碼行數:11,代碼來源:appengine.py

示例5: locked_get

  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,代碼行數:17,代碼來源:keyring_storage.py

示例6: _decode_credential_from_json

  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,代碼行數:18,代碼來源:multistore_file.py

示例7: locked_get

  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,代碼行數:18,代碼來源:appengine.py

示例8: locked_get

  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,代碼行數:21,代碼來源:file.py


注:本文中的client.Credentials類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。