Is there a way to map GAE user object and Google+ userid

旧街凉风 提交于 2019-12-11 00:55:07

问题


As mentioned here, for default authentication using python users API an object will be returned based on user's email. When user_id() is called over the object a unique id is returned, which is of course not a Google+ user id.


import webapp2
from google.appengine.api import users

class MainPage(webapp2.RequestHandler):
        def get(self):
            user = users.get_current_user()
            if user:
                if users.is_current_user_admin():
                    utype = "Admin"
                else:
                    utype = "Normal" 
                self.response.headers['Content-Type'] = 'text/html'
                self.response.out.write('Hello, ' + user.nickname() + ' Userid: ' + user.user_id() + ' User Type: ' + utype)
            else:
                self.redirect(users.create_login_url(self.request.uri))

app = webapp2.WSGIApplication([
                                ('/', MainPage)
                            ], debug=False)

Basically, I need the plus id to retrieve some user details. (via HTTP GET)

Is there any available package in AppEngine API that can provide me with google plus id for a logged in user's email?

Or should I move on to OAuth 2 for authentication purpose?

I have already completed 50% based on users API, so any help regarding the same will be appreciated.


回答1:


Yes, using their user.email()

To access properties of their Google+ profile you will need to use the Google APIs Client Library for Python https://developers.google.com/api-client-library/python/start/installation



来源:https://stackoverflow.com/questions/23052790/is-there-a-way-to-map-gae-user-object-and-google-userid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!