kei*_*ith 5 html python google-app-engine oauth
我正在使用OAuth允许我的用户使用Hunch进行OAuth,在我的网页上我有一个按钮,允许用户转到Hunch并输入他们的详细信息
<form action="/hunch" method="post" align = "right">
<div>
<input type="submit" value="Login using Hunch">
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
我怎样才能在这里调用方法而不是处理程序?因为它目前称之为:
class hunch(webapp.RequestHandler):
def post(self):
url = 'http://hunch.com/authorize/v1/?app_id=123&next=/get-recs'
self.redirect(url)
logging.info("url2 = " + url2)
auth_token_key = self.request.get('auth_token_key')
logging.info("auth_token_key = " + auth_token_key)
Run Code Online (Sandbox Code Playgroud)
但是当我打印url2时它只是打印/预感?我希望这是有道理的.
此外,它是否应该auth_token_key = self.request.get('auth_token_key')
从用户输入凭据后指向的URL获取信息?
请阅读Hunch OAuth的文档。
不是在后端拦截表单,而是直接将用户发送到
http://hunch.com/authorize/v1/?app_id=12345(提供您自己的 app_id 和可选的下一个参数)。
如果用户授权您的应用程序,他们将被重定向到redirect_url
您的应用程序的注册帐户以及auth_token_key
. 例如,带有 http://your-domain.com/authorized/ 的应用程序redirect_url
将被重定向到
此时您可以将auth_token_key
换成auth_token
.
Github 上的 Hunch 示例应用程序提供了如何完成此操作的示例。该authorize
函数生成一个页面,要求用户 Hunch 连接,并且该authorized
函数将 交换auth_token_key
为auth_token
.