infiniflow/ragflow · error · InsufficientPermissionsError

Google Drive app lacks required permissions (403). Please en

Error message

Google Drive app lacks required permissions (403). Please ensure the necessary scopes are granted and Drive apps are enabled.

What it means

Error "Google Drive app lacks required permissions (403). Please ensure the necessary scopes are granted and Drive apps are enabled." thrown in infiniflow/ragflow.

Source

Thrown at common/data_source/google_drive/connector.py:1135

        if self._primary_admin_email is None:
            raise ConnectorValidationError("Primary admin email not found in credentials. Ensure DB_CREDENTIALS_PRIMARY_ADMIN_KEY is set.")

        try:
            drive_service = get_drive_service(self._creds, self._primary_admin_email)
            drive_service.files().list(pageSize=1, fields="files(id)").execute()

            if isinstance(self._creds, ServiceAccountCredentials):
                # default is ~17mins of retries, don't do that here since this is called from
                # the UI
                get_root_folder_id(drive_service)

        except HttpError as e:
            status_code = e.resp.status if e.resp else None
            if status_code == 401:
                raise CredentialExpiredError("Invalid or expired Google Drive credentials (401).")
            elif status_code == 403:
                raise InsufficientPermissionsError("Google Drive app lacks required permissions (403). Please ensure the necessary scopes are granted and Drive apps are enabled.")
            else:
                raise ConnectorValidationError(f"Unexpected Google Drive error (status={status_code}): {e}")

        except Exception as e:
            # Check for scope-related hints from the error message
            if MISSING_SCOPES_ERROR_STR in str(e):
                raise InsufficientPermissionsError("Google Drive credentials are missing required scopes.")
            raise ConnectorValidationError(f"Unexpected error during Google Drive validation: {e}")

    @override
    def build_dummy_checkpoint(self) -> GoogleDriveCheckpoint:
        return GoogleDriveCheckpoint(
            retrieved_folder_and_drive_ids=set(),
            completion_stage=DriveRetrievalStage.START,
            completion_map=ThreadSafeDict(),
            all_retrieved_file_ids=set(),
            has_more=True,
        )

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Grant the required Drive scopes and re-authorize.
  2. Enable the Drive API and allow the app in the Workspace admin console.

Example fix

# Google Cloud Console: enable Drive API; admin console: authorize the client with drive.readonly scope

When it happens

Trigger: Thrown at common/data_source/google_drive/connector.py:1135 when the library encounters an invalid state.

Common situations: Google Drive returns 403 because required scopes or app access are missing; granting them prevents this error.


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/a7dd90f9629cda61. Report an issue: GitHub.