6 G Drive Setup
Ozzie Isaacs edited this page 2023-04-03 19:05:49 +02:00

Using Google Drive integration

Calibre library (metadata.db) can be located on a Google Drive. Additional optional dependencies are necessary to get this work. Depending on your type of installation install the dependencies via pip install calibreweb[gdrive] or for the manual installation install the dependencies by executing pip install --target vendor -r optional-requirements.txt

To use Google Drive integration, you have to use the Google Developer Console to create a new app. https://console.developers.google.com.

  1. After login create a project:

Dashboard

  1. Choose a name and save the project:

Create project

  1. Activate the API for the created project by clicking on enable APIs and services or API library

Activate API

  1. Choose Google Drive API from the listed Apps

API Library

  1. Enable the Google Drive API by clicking on enable

Enable Gdrive

  1. Click on Configure consent screen:

Configure Consent screen

  1. Enter
    your e-mail adress,
    the applications name,
    the domain name of your application
    and add scope for '../auth/drive':

Setup Credentials

Save your changes.

  1. Click on create credentials in the following screen:

Choose OAuth Client ID from the selection.

API enabled Dashboard

  1. Choose the app type: Web-application, enter in the field 'Authorized redirect URIs' the complete domain address with the callback path: CALIBRE_WEB_URL/gdrive/callback
    E.g.: For a https connection to example.com where Calibre-Web is located in the folder 'test' you have to enter: https://example.com/test/gdrive/callback The address has to be public, localhost, http://internalServername or similar wont work. The field can't be empty.

Web application

  1. Google is now presenting your client ID and your client secret. We just close the popup, we download the information.

Setup Finished

  1. Now we download the information in json format by clicking on the download button on the overview page

Download credentials

  1. Download json file and place it in ~/.calibre-web directory, with the name client_secrets.json. For manual installation place the file with the same name into the calibre-web directory.

  2. Final step is the verification of your domain. First you need to add your domain (this is the address, if you want to access your server from the internet) to the google search console (https://search.google.com/search-console):

Domain verification

  1. Please follow the steps there for verifying the domain address

The one one the right is the easiest for self hosted domains. After entering your domain name, download the html file and make it accessible under the address http[s]://[your-domain-name]/[filename]

  1. Afterwards you can enter your domain to the screen from step 14 and activate your domain

Domain verification

The Drive API should now be setup and ready to use, so we need to integrate it into Calibre-Web. This is done as described below:\

  1. Open config page (happens automatically during initial config, otherwise open "Edit Calibre Database Configuration" in admin section)

  2. Enter the location that will be used to store the metadata.db file locally, and to temporary store uploaded books and other temporary files for upload ("Location of Calibre database"). The metadata.db file has to exist and should be consistent with the books stored on Google Drive.

  3. Tick Use Google Drive
    Inital config

  4. Click the "Save" button.

  5. Now select Authenticate Google Drive
    Authenticate Google

  6. This should redirect you to Google. You are warned the app isn't verified and you have to show advanced options and click on the "Go to ... unsafe" button. After allowing it to use your Drive, it redirects you back to the previous config page of your Calibre-Web instance. Google login

Allow authenticate

  1. Select the folder that is the root of your Calibre library on Gdrive ("Google drive Calibre folder") Select Google Drive folder

  2. Click the "Save" button

  3. Google Drive should now be connected and be used to get images and download Epubs. The metadata.db is stored in the Calibre library location. Upon Upload of new books the Calibre library folder acts as temporary folder before the final upload to Google Drive.

Google Drive Optional configuration

If your Calibre-Web is using https, it is possible to add a "watch" to the drive. This will inform us if the metadata.db file is updated from outside and allows us to update our Calibre library accordingly. Additionally the public address your server uses (e.g.https://example.com) has to be verified in the Google developer console. After this is done, please wait a few minutes, then

  1. Open "Edit Calibre Database Configuration" page
  2. Click enable watch of metadata.db
  3. Note that this expires after a week, so you need manually refresh it