• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_oauth_client.TestOAuthClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中test_oauth_client.TestOAuthClient的典型用法代码示例。如果您正苦于以下问题:Python TestOAuthClient类的具体用法?Python TestOAuthClient怎么用?Python TestOAuthClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: profileScrape

def profileScrape():

    global POINTS

    resource_url = "/api/v1/user"

    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
    start = time.time()
    response = client.access_resource(resource_url, ACCESS_TOKEN)
    mongoclient = MongoClient()
    db = mongoclient.flexkhan


    start = time.time()
    parsed_json = json.loads(response)
    length = len(parsed_json)
    profile = db.profile
    find = profile.find({})
    
    dbCount = profile.find({}).count()-1

    end = time.time()
    if dbCount == 0:
        POINTS = find[0]["points"]

    if parsed_json["points"] == POINTS:
        print "Match"
    else:
        print "No Match"
        result = db.profile.insert_one(parsed_json)
        POINTS = parsed_json["points"]
开发者ID:fjbarrett,项目名称:flexkhan,代码行数:31,代码来源:updateR.py


示例2: get_api_resource

def get_api_resource():

    global result, ticker

    resource_url = "/api/v1/user/exercises/progress_changes"

    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
    start = time.time()
    response = client.access_resource(resource_url, ACCESS_TOKEN)
    end = time.time()

    print type(response)
    print "\n"
    parsed_json = json.loads(response)
    print type(parsed_json)
    length = len(parsed_json)
    mclient = MongoClient()
    db = mclient.flexkhan
    progress = db.progress
    # result = db.progress.insert_one(parsed_json[0])
    result = progress.find()
    size = result.count()
    ticker = 0
    while ticker < size:
       date = datetime.strptime(result[ticker]['date'], "%Y-%m-%dT%H:%M:%SZ")
       aware = pytz.timezone('US/Mountain').localize(date)
       utc_dt = aware.astimezone(pytz.utc)
       print utc_dt.strftime("%Y:%m:%d %I:%M:%S")
       ticker += 1

    print "\nTime: %ss\n" % (end - start)
开发者ID:fjbarrett,项目名称:flexkhan,代码行数:31,代码来源:updateR.py


示例3: progressUpdate

def progressUpdate():

    resource_url = "/api/v1/user/exercises/progress_changes"

    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
    response = client.access_resource(resource_url, ACCESS_TOKEN)
    mongoclient = MongoClient()
    db = mongoclient.flexkhan

    counter = 0
    while counter == 0:
        start = time.time()
        parsed_json = json.loads(response)
        freshSize = len(parsed_json)
        progress = db.progress
        find = progress.find({})
        currentDBCount = progress.find({}).count()
        
        if currentDBCount != freshSize:
            diff = freshSize - currentDBCount
            diffcounter = diff 
            i = 0
            while i < diffcounter:
                marker = freshSize-diff+i
                print parsed_json[marker]
                print "\n"
                print marker
                result = db.progress.insert_one(parsed_json[marker])
                i += 1
        else:
            print("No diff")
        
        # print "\nTime: %ss\n" % (end - start) 
        counter = 1 
开发者ID:fjbarrett,项目名称:flexkhan,代码行数:34,代码来源:updateR.py


示例4: get_request_token

def get_request_token():
    server = create_callback_server()

    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
    client.start_fetch_request_token('http://127.0.0.1:%d/' % server.server_address[1])

    server.handle_request()
    # REQUEST_TOKEN has now been set
    server.server_close()
开发者ID:hsingh23,项目名称:khan-api,代码行数:9,代码来源:test.py


示例5: get_api_resource

def get_api_resource():
	resource_url = raw_input("Resource relative url (/api/v1/playlists): ") or "/api/v1/playlists"
	client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
	start = time.time()
	response = client.access_resource(resource_url, ACCESS_TOKEN)
	end = time.time()
	print "\n"
	print response
	print "\nTime: %ss\n" % (end - start)
开发者ID:xmarcosx,项目名称:khan-api,代码行数:9,代码来源:test.py


示例6: get_api_resource

def get_api_resource():

    resource_url = (raw_input("Resource relative url (/api/v1/playlists): ") or
                    "/api/v1/playlists")

    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
    response = client.access_resource(resource_url, ACCESS_TOKEN)

    print "\n"
    print response
    print "\n"
开发者ID:Hao-Hsuan,项目名称:KhanLatest,代码行数:11,代码来源:test.py


示例7: get_api_resource

def get_api_resource(resource_url = '/api/v1/user/exercises/scientific_notation'):

    #resource_url = '/api/v1/user/exercises/scientific_notation' #JS# raw_input("Resource relative url (/api/v1/playlists): ") \
        #or "/api/v1/playlists"
    

    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
    start = time.time()
    response = client.access_resource(resource_url, ACCESS_TOKEN)
    end = time.time()
    return response, start, end
开发者ID:GenerationKnown,项目名称:EurlPythonServer,代码行数:11,代码来源:khanChecker.py


示例8: get_request_token

def get_request_token():
    global REQUEST_TOKEN

    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
    client.start_fetch_request_token()

    print "After logging in and authorizing, input token key and secret..."

    request_token_key = raw_input("request token: ")
    request_token_secret = raw_input("request token secret: ")

    REQUEST_TOKEN = OAuthToken(request_token_key, request_token_secret)
开发者ID:lyhiving,项目名称:khan-api,代码行数:12,代码来源:test.py


示例9: get_api_resource

    def get_api_resource(self, resourceUrl):

        # Example URLs
        # /api/v1/user/exercises/[email protected]
        # /api/v1/[email protected]
        # /api/v1/exercises

        client = TestOAuthClient(self.SERVER_URL, self.CONSUMER_KEY, self.CONSUMER_SECRET)
        start = time.time()
        response = client.access_resource(resourceUrl, self.ACCESS_TOKEN)
        end = time.time()

        # print "\nTime: %ss\n" % (end - start)
        return response
开发者ID:biffhero,项目名称:KhanReporter,代码行数:14,代码来源:KhanOAuthConnector.py


示例10: get_access_token_from_user

def get_access_token_from_user():
    client = TestOAuthClient(consts.SERVER_URL, consts.CONSUMER_KEY, consts.CONSUMER_SECRET)
    client.start_fetch_request_token()

    print "After logging in and authorizing, input token key and secret..."

    request_token_key = raw_input("request token: ")
    request_token_secret = raw_input("request token secret: ")

    request_token = OAuthToken(request_token_key, request_token_secret)
    if not request_token:
        raise IOError("Did not get request token.")

    print "Fetching access token..."
    access_token = client.fetch_access_token(request_token)
    if not access_token:
        raise IOError("Did not get access token.")

    return access_token
开发者ID:DannyBenItzhak,项目名称:analytics,代码行数:19,代码来源:get_access_token.py


示例11: api_call

def api_call(target_version, target_api_url, debug=False, authenticate=True):
    """
    Generic API call function, that will try to use an authenticated request if available,
    otherwise will fall back to non-authenticated request.
    """
    # TODO : Use requests for both kinds of authentication.
    # usage : api_call("v1", "/badges")
    resource_url = "/api/" + target_version + target_api_url
    try:
        if authenticate and REQUEST_TOKEN and ACCESS_TOKEN:
            client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
            response = client.access_resource(resource_url, ACCESS_TOKEN)
        else:
            response = requests.get(SERVER_URL + resource_url).content
        json_object = json.loads(response)
    except Exception as e:
        print e
        return {}
    if(debug):
        print json_object
    return json_object
开发者ID:aronasorman,项目名称:khan-api-python,代码行数:21,代码来源:api_models.py


示例12: authenticate

def authenticate():
    """
    Adapted from https://github.com/Khan/khan-api/blob/master/examples/test_client/test.py
    First pass at browser based OAuth authentication.
    """
    # TODO: Allow PIN access for non-browser enabled devices.

    server = create_callback_server()

    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)

    client.start_fetch_request_token(
        'http://127.0.0.1:%d/' % server.server_address[1])

    server.handle_request()

    server.server_close()

    global ACCESS_TOKEN

    ACCESS_TOKEN = client.fetch_access_token(REQUEST_TOKEN)
开发者ID:aronasorman,项目名称:khan-api-python,代码行数:21,代码来源:api_models.py


示例13: authenticate

    def authenticate(self):
        """
        Adapted from https://github.com/Khan/khan-api/blob/master/examples/test_client/test.py
        First pass at browser based OAuth authentication.
        """
        # TODO: Allow PIN access for non-browser enabled devices.

        if CONSUMER_KEY and CONSUMER_SECRET:

            server = create_callback_server(self)

            client = TestOAuthClient(
                self.SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)

            client.start_fetch_request_token(
                'http://127.0.0.1:%d/' % server.server_address[1])

            server.handle_request()

            server.server_close()

            self.ACCESS_TOKEN = client.fetch_access_token(self.REQUEST_TOKEN)
        else:
            print "Consumer key and secret not set in secrets.py - authenticated access to API unavailable."
开发者ID:FundacaoLemann,项目名称:khan-api-python,代码行数:24,代码来源:api_models.py


示例14: progressScrape

def progressScrape():

    resource_url = "/api/v1/user/exercises/progress_changes"

    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
    response = client.access_resource(resource_url, ACCESS_TOKEN)
    mongoclient = MongoClient()
    db = mongoclient.flexkhan

    counter = 0
    while counter == 0:
        
        parsed_json = json.loads(response)
        size = len(parsed_json)
        progress = db.progress
        
        i = 0
        while i < size:
            result = db.progress.insert_one(parsed_json[i])
            print("Check!")
            i += 1
        end = time.time()
        # print "\nTime: %ss\n" % (end - start) 
        counter = 1  
开发者ID:fjbarrett,项目名称:flexkhan,代码行数:24,代码来源:updateR.py


示例15: get_access_token

def get_access_token():
    global ACCESS_TOKEN

    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
    ACCESS_TOKEN = client.fetch_access_token(REQUEST_TOKEN)
开发者ID:MattFaus,项目名称:KhanReporter,代码行数:5,代码来源:test.py


示例16: get_access_token

def get_access_token():
    global ACCESS_TOKEN
    client = TestOAuthClient(SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
    ACCESS_TOKEN = client.fetch_access_token(REQUEST_TOKEN)
    store_credentials( ACCESS_TOKEN.to_string() )
开发者ID:xmarcosx,项目名称:khan-api,代码行数:5,代码来源:test.py


示例17: get_access_token

    def get_access_token(self):

        client = TestOAuthClient(self.SERVER_URL, self.CONSUMER_KEY, self.CONSUMER_SECRET)
        self.ACCESS_TOKEN = client.fetch_access_token(REQUEST_TOKEN)
开发者ID:biffhero,项目名称:KhanReporter,代码行数:4,代码来源:KhanOAuthConnector.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_p2p_autogo.autogo函数代码示例发布时间:2022-05-27
下一篇:
Python test_models.save_valid_submission函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap