GAE OAuth2.0的“进口”是什么?

时间:2013-10-11 01:42:55

标签: python google-app-engine

我正在关注this教程,了解如何让OAuth2.0登录到我的网站,我遇到了一些问题。我的网站在GAE上注册,我有我的客户ID。我还pip install编辑google-api-python-client。但是,我不知道要导入到我的项目中的内容。我的申请表中有两页。一个处理授权,另一个实际拥有页面。

authorize.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)

landing.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

非常感谢任何帮助!

〜Carpetfizz

1 个答案:

答案 0 :(得分:0)

要使用第三方模块,您需要在应用中导入它,如果这是您要问的问题, 也请查看此链接以使用external libraries in gae.

您可以查看example app for using Oauth2.0 in GAE

相关问题