infiniflow/ragflow · error · CredentialExpiredError

Invalid or expired Google Drive credentials (401).

Error message

Invalid or expired Google Drive credentials (401).

What it means

Error "Invalid or expired Google Drive credentials (401)." thrown in infiniflow/ragflow.

Source

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

        if self._creds is None:
            raise ConnectorMissingCredentialError("Google Drive credentials not loaded.")

        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(),

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Refresh or re-authorize the Google Drive credentials.
  2. Verify the token has not been revoked in Google admin console.

Example fix

# re-run the OAuth consent flow to mint fresh tokens

When it happens

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

Common situations: Google Drive returns 401 because the access/refresh token is expired or revoked; re-authorizing prevents this error.


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