有没有办法映射GAE用户对象和Google+用户ID [英] Is there a way to map GAE user object and Google+ userid
问题描述
正如此处所述,对于使用Python用户API的默认身份验证,对象将根据用户的电子邮件返回。当 user_id()
在对象上被调用时,会返回一个唯一的ID,当然这不是Google+用户标识。
从google.appengine.api导入用户
class webapp2
def get(self):
user = users.get_current_user()
if user:
如果users.is_current_user_admin():
utype =Admin
else:
utype =Normal
self.response.headers ['Content-Type'] ='text / html'
self.response.out.write('Hello,'+ user。昵称()+'userid:'+ user.user_id()+'用户类型:'+ utype)
else:
self.redirect(users.create_login_url(self.request.uri))
app = webapp2.WSGIApplication([
('/',MainPage)
],debug = Fa lse)
基本上,我需要加号来检索一些用户详细信息。 (通过 HTTP GET )
在AppEngine API中是否有可用的包可以为我提供登录用户的电子邮件的谷歌加ID?
或者我应该转到OAuth 2用于认证目的?
我已经完成了50%的基于用户API,所以任何关于相同的帮助将不胜感激。
<使用他们的user.email()
要访问他们的Google+个人资料的属性,您需要使用适用于Python的Google API客户端库 https://developers.google。 com / api-client-library / python / start / installation
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.
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
这篇关于有没有办法映射GAE用户对象和Google+用户ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!