OAuth Setup
This section walks through setting up the Google Drive connector using a OAuth-enabled Google App. Anyone can do this (even without a paid Google Workspace)!
If you’re an organization with a Google Workspace, and you’d rather use a Service Account to access Google Drive, checkout the section here.
Authorization
-
Create a Google Cloud Project
-
Enable the Google Drive API
- On the left panel, open APIs & services
- Go to Enabled APIs and services
- On the top click +ENABLE APIS AND SERVICES
- Search for Google Drive API and click ENABLE
- Alternatively visit this link, select your project and enable the Google Drive API
-
Set up the OAuth consent screen
- Under APIs & services, select the OAuth consent screen tab
- If you don’t have a Google Organization select External for User Type
- Call the app Danswer (or whatever you want)
- For the required emails, use any email of your choice or
founders@danswer.ai
if you wish for the Danswer team to help handle issues. - Click SAVE AND CONTINUE
-
Set up Scopes
- Add the scope
.../auth/drive.readonly
forGoogle Drive API
- Add the scope
-
Set up Test users
- This is only applicable for users without a Google Organization.
- Typically for a company, Danswer would be set up as an internal app so this step would not apply.
- Add at least one test user email. Only the email accounts added here will be allowed to run the OAuth flow to index new documents.
- Click SAVE AND CONTINUE, review the changes and click BACK TO DASHBOARD
- This is only applicable for users without a Google Organization.
-
Create Credentials
-
Go to the Credentials tab and select + CREATE CREDENTIALS -> OAuth client ID
-
Choose Web application and give it some name like
DanswerConnector
-
Add a Authorized JavaScript origins for
http://localhost:3000
(orhttps://<INTERNAL_DEPLOYMENT_URL>
if you have setup Danswer for production use) -
Add a Authorized redirect URIs for
http://localhost:3000/admin/connectors/google-drive/auth/callback
(orhttps://<INTERNAL_DEPLOYMENT_URL>/admin/connectors/google-drive/auth/callback
if you have setup Danswer for production use) -
Click create and on the right hand side next to Client secret, there is an option to download the credentials as a JSON. Download the JSON for use in the next step.
-
Indexing
- Navigate to the Admin Dashboard and select the Google Drive Connector.
- Select the credentials JSON from step 6 above as shown in image below, then click the Upload button to save your credentials into Danswer.
- Click on Authenticate with Google Drive
- Completing the OAuth flow will allow Danswer to index the docs that the user has read access to.
- Click the
Add
button! All Google Drive documents accessible by the user who completed step (3) will now be pulled into Danswer every 10 minutes.