本文整理匯總了Python中oauth.OAuthToken.set_verifier方法的典型用法代碼示例。如果您正苦於以下問題:Python OAuthToken.set_verifier方法的具體用法?Python OAuthToken.set_verifier怎麽用?Python OAuthToken.set_verifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類oauth.OAuthToken
的用法示例。
在下文中一共展示了OAuthToken.set_verifier方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: oauth_callback
# 需要導入模塊: from oauth import OAuthToken [as 別名]
# 或者: from oauth.OAuthToken import set_verifier [as 別名]
def oauth_callback(request):
print 'In oauth_callback'
oauth_token = request.GET['oauth_token']
oauth_secret = request.GET['oauth_token_secret']
oauth_verifier = request.GET['oauth_verifier']
request_token = OAuthToken(oauth_token, oauth_secret)
request_token.set_verifier(oauth_verifier)
request.session['request_token'] = request_token
# We do this before we redirect so that there's no "limbo" state where the
# user has a request token but no access token.
access_token = CLIENT.fetch_access_token(request_token)
request.session['oauth_token_string'] = access_token.to_string()
print "Access token is %s" % access_token.to_string()
profile = request.user.get_profile()
profile.access_token = access_token.to_string()
profile.save()
print "Your account has been associated with Khan Academy username %s" % access_token.to_string()
# We're done authenticating, and the credentials are now stored in the
# session. We can redirect back home.
return HttpResponseRedirect('/homeroom')
示例2: do_GET
# 需要導入模塊: from oauth import OAuthToken [as 別名]
# 或者: from oauth.OAuthToken import set_verifier [as 別名]
def do_GET(self):
global REQUEST_TOKEN
params = cgi.parse_qs(self.path.split('?', 1)[1], keep_blank_values=False)
REQUEST_TOKEN = OAuthToken(params['oauth_token'][0], params['oauth_token_secret'][0])
REQUEST_TOKEN.set_verifier(params['oauth_verifier'][0])
self.send_response(200)
self.send_header('Content-Type', 'text/plain')
self.end_headers()
self.wfile.write('OAuth request token fetched; you can close this window.')
示例3: do_GET
# 需要導入模塊: from oauth import OAuthToken [as 別名]
# 或者: from oauth.OAuthToken import set_verifier [as 別名]
def do_GET(self):
global REQUEST_TOKEN
params = cgi.parse_qs(self.path.split("?", 1)[1], keep_blank_values=False)
REQUEST_TOKEN = OAuthToken(params["oauth_token"][0], params["oauth_token_secret"][0])
REQUEST_TOKEN.set_verifier(params["oauth_verifier"][0])
self.send_response(200)
self.send_header("Content-Type", "text/plain")
self.end_headers()
self.wfile.write("OAuth request token fetched; you can close this window.")
示例4: oauth_callback
# 需要導入模塊: from oauth import OAuthToken [as 別名]
# 或者: from oauth.OAuthToken import set_verifier [as 別名]
def oauth_callback():
oauth_token = request.args.get('oauth_token', '')
oauth_secret = request.args.get('oauth_token_secret', '')
oauth_verifier = request.args.get('oauth_verifier', '')
request_token = OAuthToken(oauth_token, oauth_secret)
request_token.set_verifier(oauth_verifier)
session['request_token'] = request_token
# We do this before we redirect so that there's no "limbo" state where the
# user has a request token but no access token.
access_token = CLIENT.fetch_access_token(request_token)
session['oauth_token_string'] = access_token.to_string()
# We're done authenticating, and the credentials are now stored in the
# session. We can redirect back home.
return redirect(url_for('.index'))
示例5: oauth_callback
# 需要導入模塊: from oauth import OAuthToken [as 別名]
# 或者: from oauth.OAuthToken import set_verifier [as 別名]
def oauth_callback():
oauth_token = request.args.get("oauth_token", "")
oauth_secret = request.args.get("oauth_token_secret", "")
oauth_verifier = request.args.get("oauth_verifier", "")
request_token = OAuthToken(oauth_token, oauth_secret)
request_token.set_verifier(oauth_verifier)
session["request_token"] = request_token.to_string()
oauth_request = OAuthRequest.from_consumer_and_token(
consumer,
token=request_token,
http_url='http://www.khanacademy.org/api/auth/access_token',
callback=None,
parameters=None,
verifier=request_token.verifier
)
oauth_request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, request_token)
r = requests.get(oauth_request.to_url())
access_token = OAuthToken.from_string(r.text)
session['oauth_token'] = access_token.to_string()
return redirect(url_for("index"))