How to setup OAuth Server for Google Drive

Hi. I’m new to Duplicati and so far I think it’s a pretty neat tool that is going in the direction I think is useful for me. Kudos to everyone who has helped develop this program. I was looking at making an OAuth server for Google Drive and didn’t find anything here, so I thought it might be useful for people looking to setup their own. Sorry for lack of pictures or weird spacing in the URLs, it won’t let me post more.

Preq: A google account, setup for google cloud with billing setup

  • Go to console.cloud.google.com
  • Create a new project and select it (note the website will be based on the project ID - edit as needed)
  • Open a cloud shell with the icon on the left
    image
  • Copy the duplicati source files by typing in the cloud shell:
    git clone https://github.com/duplicati/oauth-handler.git
  • Change into the oauth-handler directory by typing:
    cd oauth-handler
  • Copy the config-template.py to the configuration file by typing:
    copy config-template.py config.py
  • Setup the servers and start the server by typing:
    gcloud app deploy
  • Select a location to host the server (this location cannot be changed and may impact the overall cost of the server)
  • Note the target url (you will need to type it into various places, example your.url.here)
    image
  • Choose n for now
  • Go to Hamburger menu -> APIs & Services -> Dashboard
  • Choose OAuth consent screen -> External and Create
  • Fill in
    Application Name (whatever)
    Authorized domains (your.url.here – without slashes)
    Application Homescreen (http s://your.url.here/)
    Application Privacy Policy Link (http s://your.url.here/privacy-policy.txt)
    Save (the url is based on the url copied before)
    image
  • Go to Credentials -> Create Credentials
  • Choose OAuth client ID
  • Choose Web application
  • Type some name into the box
  • Selected Authorized redirect url and enter http s://your.url.here/logged-in
  • Click Create
  • Take note of the Client ID and Secret Code (you will need it later)
  • Look for the Open Editor button on the console
  • Pop it into its own window
  • In the editor, select the config.py file
  • Change the settings for your use and uncomment (remove the #)
    APP_DOMAIN has the URL copied your.url.here
    APP_NAME is something simple like “My Custom”
    GD_CLIENT_ID and GD_CLIENT_SECRET are from the OAuth screen before
  • File -> Save
  • Go back to the console and type:
    gcloud app deploy
  • This time choose Y to continue
  • There may be prompts to turn on various APIs such as Cloud Build - follow instructions on how to enable if needed
  • Go to the search and type: Google Drive API
  • Enable this API
  • The site should be ready for use. Go to the url copied before to create new keys
  • In Duplicati, set the advanced option
    oauth-url: Alternate OAuth URL = your.url.here/refresh

That should be it. I wanted to setup my own server because this makes it so that I could have two separate computers backing up to a single google drive account, but neither has the ability to see or change the contents of the other computer.

1 Like