本文整理汇总了Python中oauth2client.clientsecrets.TYPE_WEB属性的典型用法代码示例。如果您正苦于以下问题:Python clientsecrets.TYPE_WEB属性的具体用法?Python clientsecrets.TYPE_WEB怎么用?Python clientsecrets.TYPE_WEB使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类oauth2client.clientsecrets
的用法示例。
在下文中一共展示了clientsecrets.TYPE_WEB属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load_client_secrets
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [as 别名]
def _load_client_secrets(filename):
"""Loads client secrets from the given filename.
Args:
filename: The name of the file containing the JSON secret key.
Returns:
A 2-tuple, the first item containing the client id, and the second
item containing a client secret.
"""
client_type, client_info = clientsecrets.loadfile(filename)
if client_type != clientsecrets.TYPE_WEB:
raise ValueError(
'The flow specified in {} is not supported, only the WEB flow '
'type is supported.'.format(client_type))
return client_info['client_id'], client_info['client_secret']
示例2: __init__
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [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.'
示例3: __init__
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [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.'
示例4: _load_client_secrets
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [as 别名]
def _load_client_secrets(filename):
"""Loads client secrets from the given filename."""
client_type, client_info = clientsecrets.loadfile(filename)
if client_type != clientsecrets.TYPE_WEB:
raise ValueError(
'The flow specified in {} is not supported, only the WEB flow '
'type is supported.'.format(client_type))
return client_info['client_id'], client_info['client_secret']
示例5: __init__
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [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.'
示例6: _load_client_secrets
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [as 别名]
def _load_client_secrets(self, filename):
"""Loads client secrets from the given filename."""
client_type, client_info = clientsecrets.loadfile(filename)
if client_type != clientsecrets.TYPE_WEB:
raise ValueError(
'The flow specified in {0} is not supported.'.format(
client_type))
self.client_id = client_info['client_id']
self.client_secret = client_info['client_secret']
示例7: __init__
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [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.'
示例8: test_invalid_client_type
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [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})
示例9: test_missing_required_type_web
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [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)
示例10: test_success_type_web
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [as 别名]
def test_success_type_web(self):
client_info = {
'client_id': 'eye-dee',
'client_secret': 'seekrit',
'redirect_uris': None,
'auth_uri': None,
'token_uri': None,
}
clientsecrets_dict = {
clientsecrets.TYPE_WEB: client_info,
}
result = clientsecrets._validate_clientsecrets(clientsecrets_dict)
self.assertEqual(result, (clientsecrets.TYPE_WEB, client_info))
示例11: test_success
# 需要导入模块: from oauth2client import clientsecrets [as 别名]
# 或者: from oauth2client.clientsecrets import TYPE_WEB [as 别名]
def test_success(self):
client_type, client_info = clientsecrets._loadfile(VALID_FILE)
expected_client_info = {
'client_id': 'foo_client_id',
'client_secret': 'foo_client_secret',
'redirect_uris': [],
'auth_uri': oauth2client.GOOGLE_AUTH_URI,
'token_uri': oauth2client.GOOGLE_TOKEN_URI,
'revoke_uri': oauth2client.GOOGLE_REVOKE_URI,
}
self.assertEqual(client_type, clientsecrets.TYPE_WEB)
self.assertEqual(client_info, expected_client_info)