Skip to content
Google Drive Storage for Shrine
Branch: master
Clone or download
Pull request Compare This branch is 6 commits ahead of verynear:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Provides Google Drive Storage for Shrine.

shout-outz to: &&

note: This gem uses a Google API "Service Account" to upload files to Google Drive (or a particular Drive folder). You might want to dig into shrine-google_drive_storage if you want to upload to your user's various Google Drives via oAuth.


Add this line to your application's Gemfile:

gem 'shrine-gdrive_storage'

And then execute:

$ bundle

Or install it yourself as:

$ gem install shrine-gdrive_storage

Google Drive Setup

In order to use this storage you need a Google (or Google Apps) user which will own the files, and a Google API client_secrets.json file.

  1. Go to the Google Developers console and create a new project, this option is on the top, next to the Google APIs logo.

  2. Go to "API Manager > Library" in the section "Google Apps APIs" and enable "Drive API".

  3. Go to "API Manager > Credentials" and create a new "Service Account Key".

  4. Download the client_secret_XXXXX.json file and rename it to client_secret.json.

  5. Create a google drive folder in which the files will be uploaded.

note: find the drive_public_folder_id by browsing to the folder via web at and get the id from the url, like such:

Environment variables


use the dotenv gem and add require 'dotenv/load to easily load values from your .env file

Create an .env file with these values:

# .env
APPLICATION_NAME = "yourapp-12345"

-or- set the environment variables however you like.

The application name in the above cases is the project name you chose in the Google Developers console


require "dotenv/load" #optional, load environment variables from .env file
require "shrine/storage/google_drive_storage"

Shrine.storages = {

you can use this for cache storage, too.


set the drive_public_folder_id here (instead of via environment variable) if you'd like
  drive_public_folder_id: 'AAAARRRRGGGBBBFFFFadsasdX',

Helpful info

If you are getting an "Access Not Configured" error while uploading files, this is due to this API not being enabled or, perhaps, your drive folder not having the correct permissions.

Try sharing your folder (drive_public_folder_id) with the google service account user (see https:// or client_secret.json) something like: You might want to make your folder public.

or maybe use "Enable G Suite Domain-wide Delegation" via




a quick way to make sure your client_secret.json is working:

$ ruby test/gdrive_quickstart.rb

and then run this against the nifty shrinerb linters:

$ rake test


Bug reports and pull requests are welcome on GitHub at


MIT License.

You can’t perform that action at this time.