当前位置: 首页>>代码示例>>Python>>正文


Python Common.launch_browser方法代码示例

本文整理汇总了Python中common.Common.launch_browser方法的典型用法代码示例。如果您正苦于以下问题:Python Common.launch_browser方法的具体用法?Python Common.launch_browser怎么用?Python Common.launch_browser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.Common的用法示例。


在下文中一共展示了Common.launch_browser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_access_token

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import launch_browser [as 别名]
    def get_access_token(self, client_id, client_secret):
        response_type = 'code'
        query_string = {}
        if self.provider == "google":
            query_string = (
                {'redirect_uri': self.config['REDIRECT_URI'], 'response_type': response_type,
                 'client_id': client_id,
                 'scope': self.project.config['OAUTH_SCOPE'], 'approval_prompt': 'force', 'access_type': 'offline'})
        elif self.provider == "dropbox":
            query_string = ({'response_type': response_type, 'client_id': client_id})

        params = urllib.parse.urlencode(query_string)
        step1 = self.config['OAUTH_ENDPOINT'] + '?' + params

        Common.launch_browser(step1)

        code = IO.get("Authorization Code:")
        query_string = ({'code': code, 'grant_type': 'authorization_code', 'client_id': client_id, 'client_secret': client_secret})

        if self.provider == "google":
            query_string['scope'] = ''
            query_string['redirect_uri'] = self.config['REDIRECT_URI']

        params = urllib.parse.urlencode(query_string)
        response = Common.webrequest(self.config['TOKEN_ENDPOINT'], {'content-type': 'application/x-www-form-urlencoded;charset=utf-8'}, self.http_intercept, params)
        json_response = json.loads(response)
        self.parse_token(json_response)
        self.project.save("OAUTH", self.oauth)
开发者ID:LucaBongiorni,项目名称:searchgiant_cli,代码行数:30,代码来源:OAuth2Providers.py

示例2: authorize

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import launch_browser [as 别名]
    def authorize(self):
        self.project.log("transaction", "Initiating OAUTH2 Protocol with " + self.config['TOKEN_ENDPOINT'], "info",
                         True)
        key_exists = self.oauth.get(self.key_to_the_kingdom)
        if not key_exists:
            self.project.log("transaction", "No valid {} found...".format(self.key_to_the_kingdom), "warning", True)
            c_id = self.project.config.get("CLIENT_ID")
            c_secret = self.project.config.get("CLIENT_SECRET")
            if not c_id or not c_secret:
                self.project.log("transaction", "No CLIENT_ID or CLIENT_SECRET. Asking for user input", "warning", True)

                IO.put("You must configure your account for OAUTH 2.0")
                IO.put("Please visit {}".format(self.config["OAUTH_DASHBOARD"]))
                IO.put("& Create an OAUTH 2 API Application")

                Common.launch_browser(self.config['OAUTH_DASHBOARD'])

                client_id = IO.get("{}:".format(self.config["CLIENT_ID_ALIAS"]))
                client_secret = IO.get("{}:".format(self.config["CLIENT_SECRET_ALIAS"]))

                self.project.save("CLIENT_ID", client_id)
                self.project.save("CLIENT_SECRET", client_secret)

                self.project.log("transaction",
                                 "Received {} and {} from user ({}) ({})".format(self.config['CLIENT_ID_ALIAS'],
                                                                                 self.config['CLIENT_SECRET_ALIAS'],
                                                                                 client_id, client_secret), "info",
                                 True)
                self.get_access_token(client_id, client_secret)
            else:
                self.get_access_token(self.project.config['CLIENT_ID'], self.project.config['CLIENT_SECRET'])
        else:
            self.refresh(self.project.config['CLIENT_ID'], self.project.config['CLIENT_SECRET'])

        self.project.save("OAUTH", self.oauth)
        self.project.log("transaction", "Authorization completed", "info", True)
开发者ID:LucaBongiorni,项目名称:searchgiant_cli,代码行数:38,代码来源:OAuth2Providers.py


注:本文中的common.Common.launch_browser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。