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


Python clientsecrets.TYPE_INSTALLED屬性代碼示例

本文整理匯總了Python中oauth2client.clientsecrets.TYPE_INSTALLED屬性的典型用法代碼示例。如果您正苦於以下問題:Python clientsecrets.TYPE_INSTALLED屬性的具體用法?Python clientsecrets.TYPE_INSTALLED怎麽用?Python clientsecrets.TYPE_INSTALLED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在oauth2client.clientsecrets的用法示例。


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

示例1: test_string_not_configured_type_installed

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import TYPE_INSTALLED [as 別名]
def test_string_not_configured_type_installed(self):
        string_props = clientsecrets.VALID_CLIENT[
            clientsecrets.TYPE_INSTALLED]['string']

        self.assertTrue('client_id' in string_props)
        clientsecrets_dict = {
            clientsecrets.TYPE_INSTALLED: {
                'client_id': '[[template]]',
                'client_secret': 'seekrit',
                'redirect_uris': None,
                'auth_uri': None,
                'token_uri': None,
            },
        }
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets._validate_clientsecrets(clientsecrets_dict) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:18,代碼來源:test_clientsecrets.py

示例2: __init__

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import TYPE_INSTALLED [as 別名]
def __init__(self, filename, scope, message=None, cache=None, **kwargs):
    """Constructor

    Args:
      filename: string, File name of client secrets.
      scope: string or iterable of strings, scope(s) of the credentials being
        requested.
      message: string, A friendly string to display to the user if the
        clientsecrets file is missing or invalid. The message may contain HTML
        and will be presented on the web interface for any method that uses the
        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,
    })
    revoke_uri = client_info.get('revoke_uri')
    if revoke_uri is not None:
      constructor_kwargs['revoke_uri'] = revoke_uri
    super(OAuth2DecoratorFromClientSecrets, self).__init__(
        client_info['client_id'], client_info['client_secret'],
        scope, **constructor_kwargs)
    if message is not None:
      self._message = message
    else:
      self._message = 'Please configure your application for OAuth 2.0.' 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:39,代碼來源:appengine.py

示例3: __init__

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import TYPE_INSTALLED [as 別名]
def __init__(self, filename, scope, message=None, cache=None):
    """Constructor

    Args:
      filename: string, File name of client secrets.
      scope: string or iterable of strings, scope(s) of the credentials being
        requested.
      message: string, A friendly string to display to the user if the
        clientsecrets file is missing or invalid. The message may contain HTML
        and will be presented on the web interface for any method that uses the
        decorator.
      cache: An optional cache service client that implements get() and set()
        methods. See clientsecrets.loadfile() for details.
    """
    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 = {
      '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
    super(OAuth2DecoratorFromClientSecrets, self).__init__(
        client_info['client_id'], client_info['client_secret'],
        scope, **constructor_kwargs)
    if message is not None:
      self._message = message
    else:
      self._message = 'Please configure your application for OAuth 2.0.' 
開發者ID:splunk,項目名稱:splunk-ref-pas-code,代碼行數:36,代碼來源:appengine.py

示例4: __init__

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import TYPE_INSTALLED [as 別名]
def __init__(self, filename, scope, message=None, cache=None, **kwargs):
        """Constructor

        Args:
            filename: string, File name of client secrets.
            scope: string or iterable of strings, scope(s) of the credentials
                   being requested.
            message: string, A friendly string to display to the user if the
                     clientsecrets file is missing or invalid. The message may
                     contain HTML and will be presented on the web interface
                     for any method that uses the 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,
        })
        revoke_uri = client_info.get('revoke_uri')
        if revoke_uri is not None:
            constructor_kwargs['revoke_uri'] = revoke_uri
        super(OAuth2DecoratorFromClientSecrets, self).__init__(
            client_info['client_id'], client_info['client_secret'],
            scope, **constructor_kwargs)
        if message is not None:
            self._message = message
        else:
            self._message = 'Please configure your application for OAuth 2.0.' 
開發者ID:Deltares,項目名稱:aqua-monitor,代碼行數:42,代碼來源:appengine.py

示例5: __init__

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import TYPE_INSTALLED [as 別名]
def __init__(self, filename, scope, message=None, cache=None, **kwargs):
        """Constructor

        Args:
            filename: string, File name of client secrets.
            scope: string or iterable of strings, scope(s) of the credentials
                   being requested.
            message: string, A friendly string to display to the user if the
                     clientsecrets file is missing or invalid. The message may
                     contain HTML and will be presented on the web interface
                     for any method that uses the 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 clientsecrets.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,
        })
        revoke_uri = client_info.get('revoke_uri')
        if revoke_uri is not None:
            constructor_kwargs['revoke_uri'] = revoke_uri
        super(OAuth2DecoratorFromClientSecrets, self).__init__(
            client_info['client_id'], client_info['client_secret'],
            scope, **constructor_kwargs)
        if message is not None:
            self._message = message
        else:
            self._message = 'Please configure your application for OAuth 2.0.' 
開發者ID:fniephaus,項目名稱:alfred-gmail,代碼行數:42,代碼來源:appengine.py

示例6: test_invalid_client_type

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import TYPE_INSTALLED [as 別名]
def test_invalid_client_type(self):
        fake_type = 'fake_type'
        self.assertNotEqual(fake_type, clientsecrets.TYPE_WEB)
        self.assertNotEqual(fake_type, clientsecrets.TYPE_INSTALLED)
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets._validate_clientsecrets({fake_type: None}) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:8,代碼來源:test_clientsecrets.py

示例7: test_missing_required_type_installed

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import TYPE_INSTALLED [as 別名]
def test_missing_required_type_installed(self):
        required = clientsecrets.VALID_CLIENT[
            clientsecrets.TYPE_INSTALLED]['required']
        # We will certainly have less than all 5 keys.
        self.assertEqual(len(required), 5)

        clientsecrets_dict = {
            clientsecrets.TYPE_INSTALLED: {'not_required': None},
        }
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets._validate_clientsecrets(clientsecrets_dict) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:13,代碼來源:test_clientsecrets.py

示例8: test_success_type_installed

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import TYPE_INSTALLED [as 別名]
def test_success_type_installed(self):
        client_info = {
            'client_id': 'eye-dee',
            'client_secret': 'seekrit',
            'redirect_uris': None,
            'auth_uri': None,
            'token_uri': None,
        }
        clientsecrets_dict = {
            clientsecrets.TYPE_INSTALLED: client_info,
        }
        result = clientsecrets._validate_clientsecrets(clientsecrets_dict)
        self.assertEqual(result, (clientsecrets.TYPE_INSTALLED, client_info)) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:15,代碼來源:test_clientsecrets.py

示例9: flow_from_clientsecrets

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import TYPE_INSTALLED [as 別名]
def flow_from_clientsecrets(filename, scope, redirect_uri=None,
                            message=None, cache=None, login_hint=None,
                            device_uri=None):
  """Create a Flow from a clientsecrets file.

  Will create the right kind of Flow based on the contents of the clientsecrets
  file or will raise InvalidClientSecretsError for unknown types of Flows.

  Args:
    filename: string, File name of client secrets.
    scope: string or iterable of strings, scope(s) to request.
    redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob' for
      a non-web-based application, or a URI that handles the callback from
      the authorization server.
    message: string, A friendly string to display to the user if the
      clientsecrets file is missing or invalid. If message is provided then
      sys.exit will be called in the case of an error. If message in not
      provided then clientsecrets.InvalidClientSecretsError will be raised.
    cache: An optional cache service client that implements get() and set()
      methods. See clientsecrets.loadfile() for details.
    login_hint: string, Either an email address or domain. Passing this hint
      will either pre-fill the email box on the sign-in form or select the
      proper multi-login session, thereby simplifying the login flow.
    device_uri: string, URI for device authorization endpoint. For convenience
      defaults to Google's endpoints but any OAuth 2.0 provider can be used.

  Returns:
    A Flow object.

  Raises:
    UnknownClientSecretsFlowError if the file describes an unknown kind of Flow.
    clientsecrets.InvalidClientSecretsError if the clientsecrets file is
      invalid.
  """
  try:
    client_type, client_info = clientsecrets.loadfile(filename, cache=cache)
    if client_type in (clientsecrets.TYPE_WEB, clientsecrets.TYPE_INSTALLED):
      constructor_kwargs = {
          'redirect_uri': redirect_uri,
          'auth_uri': client_info['auth_uri'],
          'token_uri': client_info['token_uri'],
          'login_hint': login_hint,
      }
      revoke_uri = client_info.get('revoke_uri')
      if revoke_uri is not None:
        constructor_kwargs['revoke_uri'] = revoke_uri
      if device_uri is not None:
        constructor_kwargs['device_uri'] = device_uri
      return OAuth2WebServerFlow(
          client_info['client_id'], client_info['client_secret'],
          scope, **constructor_kwargs)

  except clientsecrets.InvalidClientSecretsError:
    if message:
      sys.exit(message)
    else:
      raise
  else:
    raise UnknownClientSecretsFlowError(
        'This OAuth 2.0 flow is unsupported: %r' % client_type) 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:62,代碼來源:client.py


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