0

I'm following this tutorial to learn how to get OAuth2.0 login onto my site, and I'm having some problems. My site is registered on GAE and I have my client ID. I also pip installed google-api-python-client. However, I don't know what to import into my project. I have two pages in my application. One that handles authorization and one that actually has the page.

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)

My app.yaml has '-url: /.*' set to script:authorize.application

Any help would be much appreciated!

~Carpetfizz

Carpetfizz
  • 8,707
  • 22
  • 85
  • 146
  • You are trying to add a third party library (OAuth2.0) to Appengine. May be answers to this questions can help. http://stackoverflow.com/questions/4863557/how-do-i-manage-third-party-python-libraries-with-google-app-engine-virtualenv – Jayesh Oct 11 '13 at 04:40

1 Answers1

0

to use a 3rd party module you need to import it in your app, if that's what you meant to ask, also do check this link to use external libraries in gae.

You can check this example app for using Oauth2.0 in GAE

Simon K Bhatta4ya
  • 1,027
  • 2
  • 14
  • 25