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


Python clientsecrets.InvalidClientSecretsError方法代碼示例

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


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

示例1: test_string_not_configured_type_web

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

        self.assertTrue('client_id' in string_props)
        clientsecrets_dict = {
            clientsecrets.TYPE_WEB: {
                '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: test_string_not_configured_type_installed

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [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

示例3: __init__

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [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

示例4: test_with_none

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [as 別名]
def test_with_none(self):
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets._validate_clientsecrets(None) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:5,代碼來源:test_clientsecrets.py

示例5: test_with_other_than_one_key

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [as 別名]
def test_with_other_than_one_key(self):
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets._validate_clientsecrets({})
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets._validate_clientsecrets({'one': 'val', 'two': 'val'}) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:7,代碼來源:test_clientsecrets.py

示例6: test_with_non_dictionary

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [as 別名]
def test_with_non_dictionary(self):
        non_dict = [None]
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets._validate_clientsecrets(non_dict) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:6,代碼來源:test_clientsecrets.py

示例7: test_missing_required_type_web

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

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

示例8: test_missing_required_type_installed

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [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

示例9: test_non_existent

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [as 別名]
def test_non_existent(self):
        path = os.path.join(DATA_DIR, 'fake.json')
        self.assertFalse(os.path.exists(path))
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets._loadfile(path) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:7,代碼來源:test_clientsecrets.py

示例10: test_load_by_filename_missing_file

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [as 別名]
def test_load_by_filename_missing_file(self):
        with self.assertRaises(
                clientsecrets.InvalidClientSecretsError) as exc_manager:
            clientsecrets._loadfile(NONEXISTENT_FILE)

        self.assertEquals(exc_manager.exception.args[1], NONEXISTENT_FILE)
        self.assertEquals(exc_manager.exception.args[3], errno.ENOENT) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:9,代碼來源:test_clientsecrets.py

示例11: test_validation

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [as 別名]
def test_validation(self):
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets.loadfile(INVALID_FILE, cache=self.cache_mock) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:5,代碼來源:test_clientsecrets.py

示例12: credentials_from_clientsecrets_and_code

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [as 別名]
def credentials_from_clientsecrets_and_code(filename, scope, code,
                                            message = None,
                                            redirect_uri='postmessage',
                                            http=None,
                                            cache=None,
                                            device_uri=None):
  """Returns OAuth2Credentials from a clientsecrets file and an auth code.

  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 clientsecrets.
    scope: string or iterable of strings, scope(s) to request.
    code: string, An authorization code, most likely passed down from
      the client
    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.
    redirect_uri: string, this is generally set to 'postmessage' to match the
      redirect_uri that the client specified
    http: httplib2.Http, optional http instance to use to do the fetch
    cache: An optional cache service client that implements get() and set()
      methods. See clientsecrets.loadfile() for details.
    device_uri: string, OAuth 2.0 device authorization endpoint

  Returns:
    An OAuth2Credentials object.

  Raises:
    FlowExchangeError if the authorization code cannot be exchanged for an
     access token
    UnknownClientSecretsFlowError if the file describes an unknown kind of Flow.
    clientsecrets.InvalidClientSecretsError if the clientsecrets file is
      invalid.
  """
  flow = flow_from_clientsecrets(filename, scope, message=message, cache=cache,
                                 redirect_uri=redirect_uri,
                                 device_uri=device_uri)
  credentials = flow.step2_exchange(code, http=http)
  return credentials 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:44,代碼來源:client.py

示例13: flow_from_clientsecrets

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [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

示例14: credentials_from_clientsecrets_and_code

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [as 別名]
def credentials_from_clientsecrets_and_code(filename, scope, code,
                                            message=None,
                                            redirect_uri='postmessage',
                                            http=None,
                                            cache=None,
                                            device_uri=None):
    """Returns OAuth2Credentials from a clientsecrets file and an auth code.

    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 clientsecrets.
        scope: string or iterable of strings, scope(s) to request.
        code: string, An authorization code, most likely passed down from
              the client
        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.
        redirect_uri: string, this is generally set to 'postmessage' to match
                      the redirect_uri that the client specified
        http: httplib2.Http, optional http instance to use to do the fetch
        cache: An optional cache service client that implements get() and set()
               methods. See clientsecrets.loadfile() for details.
        device_uri: string, OAuth 2.0 device authorization endpoint

    Returns:
        An OAuth2Credentials object.

    Raises:
        FlowExchangeError: if the authorization code cannot be exchanged for an
                           access token
        UnknownClientSecretsFlowError: if the file describes an unknown kind
                                       of Flow.
        clientsecrets.InvalidClientSecretsError: if the clientsecrets file is
                                                 invalid.
    """
    flow = flow_from_clientsecrets(filename, scope, message=message,
                                   cache=cache, redirect_uri=redirect_uri,
                                   device_uri=device_uri)
    credentials = flow.step2_exchange(code, http=http)
    return credentials 
開發者ID:Deltares,項目名稱:aqua-monitor,代碼行數:47,代碼來源:client.py

示例15: credentials_from_clientsecrets_and_code

# 需要導入模塊: from oauth2client import clientsecrets [as 別名]
# 或者: from oauth2client.clientsecrets import InvalidClientSecretsError [as 別名]
def credentials_from_clientsecrets_and_code(filename, scope, code,
                                            message=None,
                                            redirect_uri='postmessage',
                                            http=None,
                                            cache=None,
                                            device_uri=None):
    """Returns OAuth2Credentials from a clientsecrets file and an auth code.

    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 clientsecrets.
        scope: string or iterable of strings, scope(s) to request.
        code: string, An authorization code, most likely passed down from
              the client
        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.
        redirect_uri: string, this is generally set to 'postmessage' to match
                      the redirect_uri that the client specified
        http: httplib2.Http, optional http instance to use to do the fetch
        cache: An optional cache service client that implements get() and set()
               methods. See clientsecrets.loadfile() for details.
        device_uri: string, OAuth 2.0 device authorization endpoint
        pkce: boolean, default: False, Generate and include a "Proof Key
              for Code Exchange" (PKCE) with your authorization and token
              requests. This adds security for installed applications that
              cannot protect a client_secret. See RFC 7636 for details.
        code_verifier: bytestring or None, default: None, parameter passed
                       as part of the code exchange when pkce=True. If
                       None, a code_verifier will automatically be
                       generated as part of step1_get_authorize_url(). See
                       RFC 7636 for details.

    Returns:
        An OAuth2Credentials object.

    Raises:
        FlowExchangeError: if the authorization code cannot be exchanged for an
                           access token
        UnknownClientSecretsFlowError: if the file describes an unknown kind
                                       of Flow.
        clientsecrets.InvalidClientSecretsError: if the clientsecrets file is
                                                 invalid.
    """
    flow = flow_from_clientsecrets(filename, scope, message=message,
                                   cache=cache, redirect_uri=redirect_uri,
                                   device_uri=device_uri)
    credentials = flow.step2_exchange(code, http=http)
    return credentials 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:56,代碼來源:client.py


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