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