Creating an OAuth App for Google Drive

Introduction

Google Drive is a popular cloud storage service that allows users to store and share files online. Google Drive is one of the connectors available on our File Storage API. Integrating Google Drive into your application can enhance its functionality, allowing users to access their files directly from your app. This guide will walk you through the steps to create an OAuth app for Google Drive integration.

Our sandbox application didn't go through the full Google security audit. If the app or site doesn’t meet Google's security standards, Google might block you from signing into your account via it by default. This can be turned off if you understand the risk: https://myaccount.google.com/lesssecureapps. This guide describes how to create your own sandbox application.

Step 1: Prerequisites

Before you begin, make sure you have the following:

  1. A Google account
  2. An Apideck account

Step 2: Setting up the Google Developer Console

  1. Navigate to the Google Developer Console (https://console.developers.google.com/).
  2. Sign in with your Google account.
  3. If you haven't created a project yet, click the "Create Project" button and follow the prompts. Otherwise, select an existing project.

Step 3: Enabling the Google Drive API

  1. In the Google Developer Console, click on the "Enable APIs and Services" button.
  2. Search for "Google Drive API" in the search bar and click on it.
  3. Click the "Enable" button to enable the Google Drive API for your project.

Step 4: Creating OAuth 2.0 credentials

  1. Navigate to the "Credentials" tab on the left side of the Google Developer Console.
  2. Click on the "Create credentials" button and select "OAuth client ID" from the dropdown menu.
  3. Choose the appropriate application type, depending on your project (e.g., Web application, Android, iOS, etc.).
  4. Fill in the required fields, such as "Name," "Authorized JavaScript origins," and "Authorized redirect URIs." Make sure to use the correct redirect URIs for your app.
  5. Click "Create" to generate your OAuth client ID and secret. Note down these values, as you'll need them in your application.
  1. Navigate to the "OAuth consent screen" tab on the left side of the Google Developer Console.
  2. Choose "External" or "Internal" user type, depending on your app's target audience.
  3. Fill in the required fields, such as "App name," "User support email," "App logo," "Developer contact information," etc.
  4. Under "Scopes," click the "Add or Remove Scopes" button and add the "https://www.googleapis.com/auth/drive" scope to request access to the user's Google Drive.
  5. Save your changes and submit your consent screen for verification if required.

Step 6: Configure a Custom redirect URI

To enable the connection to your Google Drive instance and be compliant with the Google certification, it is required to use your own white label auth URIs.

💡 IMPORTANT: Once you have applied one of the options, don't forget to update the "Redirect URI" in your Google Drive configuration as described in step 5.

Setup a custom subdomain for Apideck Vault

Add a custom domain name for Apideck Vault. This will allow you to white label the reference to Apideck's Vault.

  1. Create a CNAME record

Sign in to your DNS name server host and navigate to your DNS settings. Add a CNAME record with the value

cname.vercel-dns.com
.

[REPLACE_WITH_DESIRED_SUBDOMAIN] CNAME cname.vercel-dns.com.
  1. Contact Apideck

Get in touch with your Apideck contact or support@apideck.com to let us know about the custom domain you want to use, so we can configure & enable it for Apideck Vault.

  1. Wait for the changes to propagate

Congratulations! You have now pointed your custom domain to Apideck Vault! When DNS changes are made, you can expect a propagation time up to 24 hours (but mostly much less than that). This is because it takes time for the DNS to take effect across the internet. The actual time of propagation may vary in some locations based on your network setup.

  1. Update the "Redirect URI"

Update the "Redirect URI" in your Google Drive configuration as described in step 5.

  1. Save your changes and submit your consent screen for verification.

Step 7: Implementing OAuth 2.0 in your application

Now that you've set up your OAuth app, you can configure the Google Drive connector in Apideck using the client ID and secret generated earlier.

Conclusion

By following this guide, you have successfully created an OAuth app for Google Drive integration.