To make this sample run you will need to populate the client_secrets.json file found at:
%s.
with information found on the APIs Console.
""" % CLIENT_SECRETS http = httplib2.Http(memcache) service = build("plus", "v1", http=http) decorator = oauth2decorator_from_clientsecrets( CLIENT_SECRETS, scope='https://www.googleapis.com/auth/plus.me', message=MISSING_CLIENT_SECRETS_MESSAGE) class MainHandler(webapp.RequestHandler): @decorator.oauth_aware def get(self): path = os.path.join(os.path.dirname(__file__), 'grant.html') variables = { 'url': decorator.authorize_url(), 'has_credentials': decorator.has_credentials() } self.response.out.write(template.render(path, variables)) class AboutHandler(webapp.RequestHandler): @decorator.oauth_required def get(self): try: http = decorator.http() user = service.people().get(userId='me').execute(http=http) text = 'Hello, %s!' % user['displayName'] path = os.path.join(os.path.dirname(__file__), 'welcome.html') self.response.out.write(template.render(path, {'text': text })) except AccessTokenRefreshError: self.redirect('/') def main(): application = webapp.WSGIApplication( [ ('/', MainHandler), ('/about', AboutHandler), (decorator.callback_path, decorator.callback_handler()), ], debug=True) run_wsgi_app(application) if __name__ == '__main__': main()