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


Python client.OOB_CALLBACK_URN屬性代碼示例

本文整理匯總了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) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:18,代碼來源:test_tools.py

示例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) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:14,代碼來源:test_tools.py

示例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) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:14,代碼來源:test_tools.py

示例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 
開發者ID:maybelinot,項目名稱:df2gspread,代碼行數:60,代碼來源:utils.py


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