本文整理匯總了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)
示例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.'
示例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.'
示例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.'
示例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.'
示例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})
示例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)
示例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))
示例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)