From 34a64101cc6b730814dc5e96ec9107a3c4d1e0b6 Mon Sep 17 00:00:00 2001 From: Anatolii Kmetiuk Date: Wed, 4 Oct 2023 17:12:54 +0200 Subject: [PATCH] Add explanations to GoogleDriveLoader how to avoid errors (#11335) - **Description:** add a paragraph to the GoogleDriveLoader doc on how to bypass errors on authentication. For some reason, specifying credential path via `credentials_path` constructor parameter when creating `GoogleDriveLoader` makes it so that the oAuth screen is never showing up when first using GoogleDriveLoader. Instead, the `RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})` error happens. Setting it via `os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = ...` solves the problem. Also, `token_path` constructor parameter is mandatory, otherwise another error happens when trying to `load()` for the first time. These errors are tricky and time-consuming to figure out, so I believe it's good to mention them in the docs. --------- Co-authored-by: Erick Friis --- docs/extras/integrations/document_loaders/google_drive.ipynb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/extras/integrations/document_loaders/google_drive.ipynb b/docs/extras/integrations/document_loaders/google_drive.ipynb index 35b856153e7..6909301d64f 100644 --- a/docs/extras/integrations/document_loaders/google_drive.ipynb +++ b/docs/extras/integrations/document_loaders/google_drive.ipynb @@ -21,6 +21,8 @@ "## 🧑 Instructions for ingesting your Google Docs data\n", "By default, the `GoogleDriveLoader` expects the `credentials.json` file to be `~/.credentials/credentials.json`, but this is configurable using the `credentials_path` keyword argument. Same thing with `token.json` - `token_path`. Note that `token.json` will be created automatically the first time you use the loader.\n", "\n", + "The first time you use GoogleDriveLoader, you will be displayed with the consent screen in your browser. If this doesn't happen and you get a `RefreshError`, do not use `credentials_path` in your `GoogleDriveLoader` constructor call. Instead, put that path in a `GOOGLE_APPLICATION_CREDENTIALS` environmental variable.\n", + "\n", "`GoogleDriveLoader` can load from a list of Google Docs document ids or a folder id. You can obtain your folder and document id from the URL:\n", "* Folder: https://drive.google.com/drive/u/0/folders/1yucgL9WGgWZdM1TOuKkeghlPizuzMYb5 -> folder id is `\"1yucgL9WGgWZdM1TOuKkeghlPizuzMYb5\"`\n", "* Document: https://docs.google.com/document/d/1bfaMQ18_i56204VaQDVeAFpqEijJTgvurupdEDiaUQw/edit -> document id is `\"1bfaMQ18_i56204VaQDVeAFpqEijJTgvurupdEDiaUQw\"`" @@ -59,6 +61,7 @@ "source": [ "loader = GoogleDriveLoader(\n", " folder_id=\"1yucgL9WGgWZdM1TOuKkeghlPizuzMYb5\",\n", + " token_path='/path/where/you/want/token/to/be/created/google_token.json'\n", " # Optional: configure whether to recursively fetch files from subfolders. Defaults to False.\n", " recursive=False,\n", ")"