Skip to main content

Authenticate with Google APIs using OAuth 2.0

Learn how to use OAuth 2.0 to authenticate with Google APIs.

In some cases, you may need to use OAuth 2.0 credentials for a Google Cloud project. These can include:

  • Accessing Google Sheets from a self-hosted deployment.
  • Creating a resource to use a Google API for which Retool does not have a built-in integration.

If you are already using Okta SSO using OpenID Connect (OIDC), you can safely authorize Google SSO without presenting an additional sign in method. Retool only displays one SSO button on the login page and Okta has priority over Google when both are enabled.


This guide assumes you have an existing Google Cloud project. If not, create a new project first.

Create OAuth 2.0 credentials

Follow Google's Setting up OAuth 2.0 guide to create an OAuth 2.0 client ID. Use the following information to configure it for use with Retool.

Application typeWeb application
JavaScript origin URIThe base URL you use to access Retool (e.g., or
Authorized redirect URIsBASE_URL/oauth/oauthcallback and BASE_URL/oauth/user/oauthcallback.

Once complete, Google displays the client ID and secret, and also makes it available for download in JSON format. You use these credentials to create Google API resources in Retool.

Enable APIs and define scope

Before you can create a resource in Retool, you must enable the desired APIs and define the scope of access that the credentials will request from users.

First, enable any APIs you wish to use with this project. These will be accessible using the OAuth credentials once you define their scope.

Next, follow Google's guide to configure the OAuth consent screen and define the scopes with which the OAuth credentials will request for any enabled APIs. For example, the auth/calendar/events scope for the Google Calendar API would allow Retool to view and edit all calendar events once a user completes authorization.

Create a REST API resource

You can now create REST API resources for Google APIs, such as the Google Calendar API, with the following settings:

Base URLThe base URL of the API (e.g.,
HeadersA key-value pair set to Authorization and Bearer OAUTH2_TOKEN.
Authentication typeOAuth 2.0.
Authorization URL
Access token URL
Client IDThe client ID provided by Google.
Client secretThe client secret provided by Google.
ScopesA space-separated list of scopes (e.g.,