Skip to content
Skip to main content

Creating a Google auth app

Last updated:

Create a Google Cloud project and an OAuth client so your users can connect their Google accounts to your Nylas application. The setup has six parts: create a project, enable the APIs, configure Google Auth Platform, add scopes, create an OAuth client, and add a Google connector.

Make two decisions before you create the project.

  • Hosted OAuth is the fastest way to get started. Use it if you don’t need to customize the auth flow, or to test with a few users.
  • Bring Your Own (BYO) Authentication lets you customize the auth flow. Your users see your company name instead of “Nylas” on the OAuth screen. It requires an existing Nylas application and a callback URI.

The audience controls which Google accounts can authenticate with your app.

InternalExternal
Who can authenticateUsers in your organization, such as @example.comAny Google account
Starting statusAvailable to your organization immediatelyTesting. Only test users that you add can authenticate until you publish the app
Google verificationNot requiredRequired before more than 100 users can authenticate. Users see an unverified app warning until then

For more information about the 100-user limit, see Google’s Unverified apps documentation. For the verification steps, see the Google verification and security assessment guide.

A Google Cloud project holds the APIs, OAuth settings, and credentials for your Google auth app.

  1. Go to the New Project page in the Google Cloud console.
  2. Enter a Project name.
  3. Select your Organization and Parent resource. The New Project page in the Google Cloud console, with the project name, organization, and parent resource filled in.
  4. Click Create.
  5. In the Notifications panel, click Select Project under the new project. The Notifications panel showing a Create Project notification with a Select Project link.

Enable three Google APIs in the project. Add the Admin SDK API if you need room resources.

  1. From the navigation menu, select APIs & Services, then click Enable APIs and services.
  2. Search for an API from the following table, select it, and click Enable. The Gmail API page in the Google Cloud API Library, with the Enable button.
  3. Repeat step 2 for each API you need.
APIRequired for
Gmail APIMessages, Threads, Drafts, Folders, and Attachments endpoints
Google Calendar APICalendars, Events, and Availability endpoints
People APIContacts endpoints
Admin SDK APIOptional. Room resources for calendar events

Google Auth Platform holds the app name, audience, and contact details that Google shows on the OAuth consent screen. The first-time setup has four steps.

  1. From the navigation menu, select Google Auth Platform, then click Get started.
  2. Under App Information, enter an App name, select a User support email, and click Next.
  3. Under Audience, select Internal or External and click Next. The Audience step of the Google Auth Platform setup, with the External option selected.
  4. Under Contact Information, enter the email addresses that Google notifies about changes to your project, and click Next.
  5. Under Finish, review the Google API Services: User Data Policy, select the agreement checkbox, and click Continue.
  6. Click Create.

To change these settings later, use the Branding and Audience pages.

You might need to take extra steps to comply with Google’s OAuth 2.0 policies and complete their verification process before you can publish your Google Cloud project.

Be sure to request the most restrictive scopes that you need for your project. If you request any of Google’s restricted scopes, Google will require your application to complete a security assessment. This could extend your verification timeline significantly, or cause Google to fail your review.

For more information, see Nylas’ Google verification and security assessment guide.

Add every scope your application uses to the Data Access page, and always include the three marked as required in the following table. Nylas requests openid, userinfo.email, and userinfo.profile on every Google auth request whether or not your connector lists them. Your connector or auth request then names only the feature scopes, in the full URI form.

Google scope URIDescription
https://www.googleapis.com/auth/userinfo.emailRequired Google scope.
https://www.googleapis.com/auth/userinfo.profileRequired Google scope.
openidRequired Google scope.
https://www.googleapis.com/auth/gmail.modifyRead, compose, and send messages from a Gmail account.
https://www.googleapis.com/auth/gmail.readonlyView messages.
https://www.googleapis.com/auth/gmail.labelsView and edit Gmail labels.
https://www.googleapis.com/auth/gmail.composeCreate drafts and send messages.
https://www.googleapis.com/auth/gmail.sendSend messages.
https://www.googleapis.com/auth/gmail.metadataGet message metadata.
https://www.googleapis.com/auth/calendarView, create, edit, and delete calendars and events.
https://www.googleapis.com/auth/calendar.readonlyView calendars and events.
https://www.googleapis.com/auth/calendar.eventsView and edit events on all calendars.
https://www.googleapis.com/auth/calendar.events.readonlyView events on all calendars.
  1. In Google Auth Platform, select Data Access and click Add or remove scopes.
  2. Select .../auth/userinfo.email, .../auth/userinfo.profile, and openid.
  3. Under Manually add scopes, enter the full URI of each feature scope, separated by commas or new lines, and click Add to table.
  4. Click Update.
  5. On the Data Access page, click Save.

The Data Access page groups your scopes as non-sensitive, sensitive, or restricted. Sensitive and restricted scopes require Google verification for external apps.

The Data Access page in Google Auth Platform. The calendar scope is listed as sensitive, and the gmail.compose and gmail.modify scopes are listed as restricted.

Automatically include previously granted scopes

Section titled “Automatically include previously granted scopes”

Nylas sets Google’s include_granted_scopes parameter on Google OAuth 2.0 requests. Google then includes any scopes the user already approved for your Google auth app, so users don’t re-select those scopes when they authenticate again.

An external app starts with a Testing publishing status. While the status is Testing, only the test users you add on the Audience page can authenticate, and Google counts them toward the 100-user cap.

  1. In Google Auth Platform, select Audience. The Audience page in Google Auth Platform, showing a Testing publishing status, an External user type, and the OAuth user cap.
  2. To test before you publish, click Add users under Test users and enter the Google accounts to test with.
  3. When you’re ready for any Google account to authenticate, click Publish app under Publishing status.

If Publish app is unavailable, complete your configuration on the Branding page first.

After you publish the app, you authorize users with the Nylas APIs instead of adding them as test users. Google lists the app as unverified until you complete its security review process. Internal apps skip this section.

Nylas needs your Google auth app’s client ID and client secret to authenticate users. You get both when you create an OAuth client.

  1. In Google Auth Platform, select Clients and click Create client.

  2. Set the Application type to Web application.

  3. Enter a Name. Google shows this name only in the console.

  4. Under Authorized redirect URIs, click Add URI and enter the URI for your authentication method:

    • U.S. Hosted OAuth: https://api.us.nylas.com/v3/connect/callback
    • E.U. Hosted OAuth: https://api.eu.nylas.com/v3/connect/callback
    • BYO Authentication: Your project’s callback URI.

    The Create OAuth client ID page with the Nylas U.S. callback URI entered under Authorized redirect URIs.

  5. Click Create.

  6. Copy the client ID and client secret, or click Download JSON, before you close the dialog. The OAuth client created dialog, showing the client ID, the client secret, and the Download JSON button.

Google adds the domain of each redirect URI to the Authorized domains list on the Branding page. New client settings can take from 5 minutes to a few hours to take effect.

Add [email protected] to your Google Cloud project as an owner. Google verification requires this if you use Hosted OAuth, and it lets the Nylas Support team diagnose issues with your Google auth app.

  1. From the navigation menu, select IAM & Admin > IAM.
  2. Click Grant access.
  3. Enter [email protected] in New principals.
  4. Under Select a role, search for Owner and select Owner (Legacy). The Grant access panel in Google Cloud IAM, with support@nylas.com as the new principal and the Owner (Legacy) role selected.
  5. Click Save.

Your application needs a “Sign in with Google” button that meets Google’s branding guidelines. This applies to the OAuth flow for both personal Gmail (@gmail.com) and Google Workspace email addresses.

For Hosted authentication, Nylas recommends you do one of the following:

  • Configure the OAuth login prompt by setting the prompt parameter with select_provider or detect,select_provider. For more information, see Configuring the OAuth login prompt.
    • If you add a login_hint that’s a personal Gmail or Workspace email address and you don’t configure a prompt during the Hosted auth flow, the user is immediately directed to the Google OAuth screen, without clicking the “Sign in with Google” button. This can result in delays or failure in verification.
  • Use the pre-approved “Sign in with Google” button with the “Connect your account” button or other provider login buttons in your application. For more information, see Google’s official Sign in with Google branding guidelines.

For Bring Your Own Authentication, use the pre-approved “Sign in with Google” button with the “Connect your account” button or other provider login buttons in your application.

A connector stores your Google client ID, client secret, and default scopes in your Nylas application. Create it in the Dashboard or with the API.

  1. In the Nylas Dashboard, open your application and select Connectors.
  2. In the Google row, click Configure.
  3. Select Use your own Google OAuth credentials.
  4. Enter a Credential name. The Dashboard shows this name; API requests use the credential’s ID.
  5. Enter the Google OAuth client ID and Google OAuth client secret.
  6. Under Connector settings, enter the Google Pub/Sub topic name and select the OAuth scopes your users are asked to grant.
  7. Click Save.

The Configure Google connector dialog in the Nylas Dashboard, with a credential name, client ID, and client secret entered.

If the Google connector already exists, add the Google Cloud project as another credential instead. See Using multiple provider applications.

Make a Create Connector request with your client ID, client secret, Pub/Sub topic name, and scopes.

curl -X POST 'https://api.us.nylas.com/v3/connectors' \
--header 'Authorization: Bearer <NYLAS_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"name": "google example",
"provider": "google",
"settings":
{
"client_id": "<GOOGLE_CLIENT_ID>",
"client_secret": "<GOOGLE_CLIENT_SECRET>",
"topic_name": "<PUBSUB_TOPIC_NAME>"
},
"scope": [
"openid",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/gmail.compose",
"https://www.googleapis.com/auth/gmail.modify"
]
}'

Set up the Google auth app with a browser agent

Section titled “Set up the Google auth app with a browser agent”

An AI agent that can control your browser can complete the Google Cloud console steps on this page. Copy the following sample prompt, replace the placeholder values, and run it in a browser where you’re already signed in to Google Cloud. The prompt keeps the policy agreement, publishing, and client secret steps with you.

Sample prompt: set up the Google auth app
Set up a Google Cloud project for use with Nylas in my signed-in browser at
https://console.cloud.google.com. Follow the steps at
https://developer.nylas.com/docs/provider-guides/google/create-google-app/
(request the page with "Accept: text/markdown" if you can).
Inputs
- Project name: <PROJECT_NAME>
- Audience: <Internal or External>
- Nylas region: <US or EU>
- Feature scopes (full URIs): <SCOPE_URIS>
- User support and contact email: <EMAIL>
Steps
1. Create the project, then select it. Before every later step, confirm the
project picker shows <PROJECT_NAME>.
2. Enable the Gmail API, Google Calendar API, and People API.
3. Open Google Auth Platform, click Get started, and complete App Information,
Audience, and Contact Information with the inputs above.
4. On the Data Access page, add openid, userinfo.email, userinfo.profile, and
each feature scope. Click Update, then Save.
5. On the Clients page, create a Web application client with this authorized
redirect URI: https://api.us.nylas.com/v3/connect/callback for US, or
https://api.eu.nylas.com/v3/connect/callback for EU.
Rules
- Stop and ask me before you agree to the Google API Services User Data
Policy, click Publish app, or grant any IAM role.
- When the OAuth client is created, don't read, copy, or screenshot the client
secret. Tell me the dialog is open so that I can download the JSON myself.
- Don't enter passwords or complete sign-in prompts. If Google asks me to sign
in, stop and tell me.
- Don't change any project other than <PROJECT_NAME>.
When you finish, report the project ID, the client ID, the enabled APIs, the
scopes on the Data Access page, and the publishing status.