本文整理汇总了Python中test_oauth_client.TestOAuthClient.start_fetch_request_token方法的典型用法代码示例。如果您正苦于以下问题:Python TestOAuthClient.start_fetch_request_token方法的具体用法?Python TestOAuthClient.start_fetch_request_token怎么用?Python TestOAuthClient.start_fetch_request_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test_oauth_client.TestOAuthClient
的用法示例。
在下文中一共展示了TestOAuthClient.start_fetch_request_token方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_request_token
# 需要导入模块: from test_oauth_client import TestOAuthClient [as 别名]
# 或者: from test_oauth_client.TestOAuthClient import start_fetch_request_token [as 别名]
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()
示例2: get_request_token
# 需要导入模块: from test_oauth_client import TestOAuthClient [as 别名]
# 或者: from test_oauth_client.TestOAuthClient import start_fetch_request_token [as 别名]
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)
示例3: get_access_token_from_user
# 需要导入模块: from test_oauth_client import TestOAuthClient [as 别名]
# 或者: from test_oauth_client.TestOAuthClient import start_fetch_request_token [as 别名]
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
示例4: authenticate
# 需要导入模块: from test_oauth_client import TestOAuthClient [as 别名]
# 或者: from test_oauth_client.TestOAuthClient import start_fetch_request_token [as 别名]
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)
示例5: authenticate
# 需要导入模块: from test_oauth_client import TestOAuthClient [as 别名]
# 或者: from test_oauth_client.TestOAuthClient import start_fetch_request_token [as 别名]
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."