Can User Role from Google Apps be retrieved inside Google App Engine Application

319 views Asked by At

I have a Google App Engine application for the use of Google Apps users. For that I need the roles and priviledges of users to be reflected in Google App Engine application. But using UserServices API I am only able to retrieve nick name, email ID all the details. But I found no way for retrieving the Role assigned to a particular user inside my GAE application.

2

There are 2 answers

4
Lipis On BEST ANSWER

There is no way to get the exact role of the user that you have assigned in your GAE dashboard, but you can check if the currently logged in user is on that list. If you are using Python here is how you can achieve that:

from google.appengine.api import users

user = users.get_current_user()

if user:
    print 'Welcome, %s!' % user.nickname()
    if users.is_current_user_admin():
        print '<a href="/admin/">Go to admin area</a>'
0
David Cifuentes On

If you want to use the Google Apps admin roles (super admin or delegated admin) instead of the App Engine permissions you should implement it yourself by synchronizing your own users entities in the datastore against the directory API part of the admin SDK of Google Apps, specifically with the fields isAdmin or isDelegatedAdmin.