Connecting to Google Workspace with the Web API data source

Recently, I wanted to dashboard user information from Google Workspace. I was able to achieve this with the Google Directory API.

It’s important to note that Google Workspace features many different APIs for the various types of data you may wish to query. Nearly all of these APIs should be accessible in the way shown below.

The only API I found not to work was the Identity API when querying devices. I suppose Google considers this data more sensitive and seems only accessible with a service account and not OAuth. I found many unresolved posts on Google’s community answers forum regarding this, but it isn’t mentioned in the official docs. However, I believe 95% of the Google Workspace APIs should work without a problem.

Thank you to ‘agt’, the author of this post; this method is similar, but there are some differences when comparing GCP APIs to Google Workspace APIs: Connecting to GCP using OAuth and the Web API Data Source

Here’s how to connect:

Step 1: Ensure you are a Super Admin in the Google Workspace console

  • Access the Google Admin console: Log in to the Google Admin console using a Super Admin account.
  • Confirm Super Admin status: Verify that your account has Super Admin permissions. If not, you’ll need to be granted Super Admin access by another administrator.

Step 2: Create an OAuth Client ID and secret in the GCP console

  1. Create a GCP project: If you don’t already have one, create a new GCP project associated with your Google Workspace organization.
  2. Go to the API Credentials page: Navigate to the API Credentials page within the GCP console.
  3. Create a new OAuth 2.0 client ID: Click on “Create credentials” and select “OAuth 2.0 client ID”.
  4. Configure the client ID:
    • Application type: Select “Web application”
    • Authorized redirect URIs: Add https://app.squaredup.com/settings/pluginsoauth2
  5. Save the client ID and secret: After creating the client ID, you’ll be provided with a client secret. Make sure to save both the client ID and secret in a secure location.

Step 3: Enable the required API in the GCP console

  1. Go to the API Library: In the GCP console, navigate to the API Library.
  2. Search for the API: Search for the specific Google Workspace API you want to use (e.g., Google Directory API).
  3. Enable the API: Click on the API and then click the “Enable” button.

Step 4: Configure the Web API data source in SquaredUp

  • Base URL: From the GCP API docs. For example, for the Directory API, it would be: https://admin.googleapis.com/admin/directory/v1
  • Add your Google Workspace domain in Query Arguments:
    • Domain: example.com (replace with your domain)
  • Authentication: OAuth 2
  • Token URL: https://oauth2.googleapis.com/token
  • Client ID: <Client ID from step 2>
  • Client Secret: <Client secret from step 2>
  • Authorization Scope: You can find this on the docs page for the HTTP endpoint. For example, for the Directory API, it is: https://www.googleapis.com/auth/admin.directory.user.readonly
  • How to send credentials to the Token URL: Query string
  • Grant Type: Authorization Code
  • Authorization URL: https://accounts.google.com/o/oauth2/auth?access_type=offline&include_granted_scopes=true&response_type=code

Important: Save your data source settings at this point before clicking “Sign In.” This will save your settings in case something goes wrong.

  • Click ‘Sign in’ to sign in with your admin workspace account. You should now be authenticated!

Now you can make a test request to ensure it is working. A simple test for the Directory API is:

  • Endpoint path to test: /users
  • HTTP method for the test: GET
  • Send!