2015-03-31 3 views
0

Я пытаюсь написать базовое приложение GAE для тестирования OpenId Connect. Он не работает с ошибкой в ​​журналах: «Недостаточное разрешение» для людей(). Get(). Похоже, что эта программа запрашивает учетные данные OpenId, а не OAuth (есть перенаправление на https://accounts.google.com/o/openid2/auth на URL-адрес страницы входа, но это неявно. Как явно запрашивать OAuth? Странно, что decorator.has_credentials() возвращает True с эти OpenId полномочия ...Реализация Google connect с openId Connect в GAE

import logging 
import webapp2 
from apiclient.discovery import build 
from oauth2client.appengine import OAuth2Decorator 
from 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 the profile data 
     self.response.write(unicode(response)) 
    else: 
     url = decorator.authorize_url() 
     # Write a page explaining why authorization is needed, 
     # and provide the user with a link to the url to proceed. 
     # When the user authorizes, they get redirected back to this path, 
     # and 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) 
+0

Кажется, что был использован OpenID 2.0, а не OAuth 2 (сообщение cf на экране авторизации) – frank

ответ

Смежные вопросы