python - Implementing Google connect with openId Connect on GAE -
i'm trying write basic gae app test openid connect. fails error in logs : "insufficient permission" on people().get(). seems program asks openid credentials , not oauth (there redirect https://accounts.google.com/o/openid2/auth in login page url. implicit. how explicitly ask oauth? strange decorator.has_credentials() returns true these openid credentials...
import logging import webapp2 apiclient.discovery import build oauth2client.appengine import oauth2decorator google.appengine.api import users decorator = oauth2decorator( client_id='123456789999.....googleusercontent.com', client_secret='abcdef.........', scope=['https://www.googleapis.com/auth/plus.login']) service = build('plus', 'v1') class mainhandler(webapp2.requesthandler): @decorator.oauth_aware def get(self): if decorator.has_credentials(): response =service.people().get(userid="me").execute(http=decorator.http()) # write profile data self.response.write(unicode(response)) else: url = decorator.authorize_url() # write page explaining why authorization needed, # , provide user link url proceed. # when user authorizes, redirected path, # , has_credentials() returns true. self.response.write('you must login : <a href="'+url+'">go</a>') app = webapp2.wsgiapplication([ ('/', mainhandler), (decorator.callback_path, decorator.callback_handler())], debug=true)
you have activate google+ api in google console http://code.google.com/apis/console.
apis & auth / apis / google+ api
and click in button text: "enable api"
Comments
Post a Comment