本文整理汇总了Python中oauth2client.client.OOB_CALLBACK_URN属性的典型用法代码示例。如果您正苦于以下问题:Python client.OOB_CALLBACK_URN属性的具体用法?Python client.OOB_CALLBACK_URN怎么用?Python client.OOB_CALLBACK_URN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类oauth2client.client
的用法示例。
在下文中一共展示了client.OOB_CALLBACK_URN属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_run_flow_webserver_fallback
# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import OOB_CALLBACK_URN [as 别名]
def test_run_flow_webserver_fallback(
self, input_mock, server_ctor_mock, logging_mock):
server_ctor_mock.side_effect = socket.error()
input_mock.return_value = 'auth_code'
# It should catch the socket error and proceed as if
# noauth_local_webserver was specified.
returned_credentials = tools.run_flow(
self.flow, self.storage, flags=self.server_flags)
self.assertEqual(self.credentials, returned_credentials)
self.assertEqual(self.flow.redirect_uri, client.OOB_CALLBACK_URN)
self.flow.step2_exchange.assert_called_once_with(
'auth_code', http=None)
self.assertTrue(server_ctor_mock.called)
self.assertFalse(self.server.handle_request.called)
示例2: test_run_flow_no_webserver
# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import OOB_CALLBACK_URN [as 别名]
def test_run_flow_no_webserver(self, input_mock, logging_mock):
input_mock.return_value = 'auth_code'
# Successful exchange.
returned_credentials = tools.run_flow(self.flow, self.storage)
self.assertEqual(self.credentials, returned_credentials)
self.assertEqual(self.flow.redirect_uri, client.OOB_CALLBACK_URN)
self.flow.step2_exchange.assert_called_once_with(
'auth_code', http=None)
self.storage.put.assert_called_once_with(self.credentials)
self.credentials.set_store.assert_called_once_with(self.storage)
示例3: test_run_flow_no_webserver_explicit_flags
# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import OOB_CALLBACK_URN [as 别名]
def test_run_flow_no_webserver_explicit_flags(
self, input_mock, logging_mock):
input_mock.return_value = 'auth_code'
# Successful exchange.
returned_credentials = tools.run_flow(
self.flow, self.storage, flags=self.flags)
self.assertEqual(self.credentials, returned_credentials)
self.assertEqual(self.flow.redirect_uri, client.OOB_CALLBACK_URN)
self.flow.step2_exchange.assert_called_once_with(
'auth_code', http=None)
示例4: get_credentials
# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import OOB_CALLBACK_URN [as 别名]
def get_credentials(credentials=None, client_secret_file=CLIENT_SECRET_FILE, refresh_token=None):
"""Consistently returns valid credentials object.
See Also:
https://developers.google.com/drive/web/quickstart/python
Args:
client_secret_file (str): path to client secrets file, defaults to .gdrive_private
refresh_token (str): path to a user provided refresh token that is already
pre-authenticated
credentials (`~oauth2client.client.OAuth2Credentials`, optional): handle direct
input of credentials, which will check credentials for valid type and
return them
Returns:
`~oauth2client.client.OAuth2Credentials`: google credentials object
"""
# if the utility was provided credentials just return those
if credentials:
if _is_valid_credentials(credentials):
# auth for gspread
return credentials
else:
print("Invalid credentials supplied. Will generate from default token.")
token = refresh_token or DEFAULT_TOKEN
dir_name = os.path.dirname(DEFAULT_TOKEN)
try:
os.makedirs(dir_name)
except OSError:
if not os.path.isdir(dir_name):
raise
store = file.Storage(token)
credentials = store.get()
try:
import argparse
flags = argparse.ArgumentParser(
parents=[tools.argparser]).parse_known_args()[0]
except ImportError:
flags = None
logr.error(
'Unable to parse oauth2client args; `pip install argparse`')
if not credentials or credentials.invalid:
flow = client.flow_from_clientsecrets(
client_secret_file, SCOPES)
flow.redirect_uri = client.OOB_CALLBACK_URN
if flags:
credentials = tools.run_flow(flow, store, flags)
else: # Needed only for compatability with Python 2.6
credentials = tools.run(flow, store)
logr.info('Storing credentials to ' + DEFAULT_TOKEN)
return credentials