【发布时间】:2013-10-11 01:42:54
【问题描述】:
我正在关注this 教程来学习如何让 OAuth2.0 登录到我的网站,但我遇到了一些问题。我的网站已在 GAE 上注册,并且我有我的客户 ID。我也 pip installed google-api-python-client。但是,我不知道将什么导入到我的项目中。我的应用程序中有两个页面。一个处理授权,一个实际拥有页面。
授权.py
import cgi, webapp2
from google.appengine.api import users
LOGIN_PAGE_HTML="""\
<html>
<body>
<input type="submit" method="post" action="/AuthorizeUser"/>
</body>
</html>
"""
class LoginPage(webapp2.RequestHandler):
def get(self):
self.response.write(LOGIN_PAGE_HTML)
class AuthorizeUser(webapp2.RequestHandler):
def post(self):
state = ''.join(random.choice(string.ascii_uppercase + string.digits)for x in xrange(32))
session['state'] = state
response = make_response('/LandingPage',
CLIENT_ID='MY ID',
STATE=state
APPLICATION_NAME='Summit Tech Help'))
if request.args.get('state','') != session['state']:
response = make_response(json.dumps('Invalid state parameter.'), 401)
response.headers['Content-Type'] = 'application/json'
return response
application = webapp2.WSGIApplication([
('/',LoginPage),
('/AuthorizeUser',AuthorizeUser),
], debug=True)
登陆.py
import cgi, webapp2
from google.appengine.api import mail
LANDING_PAGE_HTML="""\
<html>
<body>
<p>test</p>
</body>
</html>
"""
class LandingPage(webapp2.RequestHandler):
def get(self):
self.response.write(LANDING_PAGE_HTML)
application = webapp2.WSGIApplication([
('LandingPage',LandingPage),
],debug=True)
我的app.yaml 将'-url: /.*' 设置为script:authorize.application
任何帮助将不胜感激!
~地毯嘶嘶声
【问题讨论】:
-
您正在尝试将第三方库 (OAuth2.0) 添加到 Appengine。可能是这个问题的答案可以提供帮助。 stackoverflow.com/questions/4863557/…