Search code examples
google-app-enginegoogle-appsgae-userservice

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


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.


Solution

  • 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>'