Google Workspace OAuth – Allow Only Certain Accounts to Sign In Using OAuth

authenticationgoogle-apps

Is there possibility to allow login to app only for certain users from Google Apps. From only one app to be more specific. I want to create admin panel that only some people can manage but I want to allow admins to login using OAuth. It will create all process simpler and more user-friendly. Have you any sources how to do it if it is possible?

Best Answer

I assume you want to create your control panel app so that users can log in to it via Google's login services. If that's the case, you can limit access to your app in at least two different ways:

  1. If you follow these guidelines, that is, create your control panel app with Google Apps in mind, it will be installed along your existing Google Services. As such, you can disable/enable your app for different organizational units, via the Google Apps control panel. This method requires you to have users in different organizational units (OUs), which might be undesirable (a user can only belong to a single OU, for example).

  2. In your control panel app, make a call to the Google Apps Provisioning API to get a list of the current user's group memberships. Deny access to your control panel if the user is not a member of the required group. This method does not require you to divide users into different OUs, but have them assigned to groups instead. Instead of groups, you might want to create a role which you assign your users. ATM I cannot find an API for retrieving a user's roles, though.