README.md in drive_env-0.3.1 vs README.md in drive_env-0.4.0

- old
+ new

@@ -34,12 +34,14 @@ $ gem install drive_env ## Usage -First, you need to login Google Cloud Platform and enable APIs. +First, you need to login Google Cloud Platform and enable APIs. We support authentication with `User account` and `Service account`. +### User authentication + 1. Open [API library page](https://console.developers.google.com/apis/library) 2. Create/Select project 3. Enable "Google Drive API" and "Google Sheets API" 4. Open [Credentials page](https://console.developers.google.com/apis/credentials) in the same project 5. Click "Create credentials" and choose "OAuth client ID" @@ -54,10 +56,27 @@ $ drive_env auth login ``` Now you have access token and refresh token, you can access to Google APIs. +### Service account authentication + +1. Open [API library page](https://console.developers.google.com/apis/library) +2. Create/Select project +3. Enable "Google Drive API" and "Google Sheets API" +4. Open [Credentials page](https://console.developers.google.com/apis/credentials) in the same project +5. Click "Create credentials" and choose "Service account key" +6. Save credentials as JSON file +7. Set `GOOGLE_APPLICATION_CREDENTIALS` environment variables with the value of the downloaded JSON file path. + ``` + $ export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service_account_credential.json" + ``` + +The application search `GOOGLE_APPLICATION_CREDENTIALS` first and then try to use user credential. + +### Access Spreadsheet + Show Spreadsheet in Google Drive: ``` $ drive_env spreadsheet show 'https://docs.google.com/spreadsheets/d/*********/edit#gid=0' ``` @@ -97,11 +116,11 @@ $ your-ruby-application-with-dotenv-gem ``` ## Development -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. +After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing @@ -109,6 +128,5 @@ ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). -