Add example for auth with ENV vars (#156)
This commit is contained in:
parent
a07011bb45
commit
b4516ab3d1
20
README.md
20
README.md
|
@ -151,6 +151,26 @@ export GOOGLE_CLIENT_EMAIL=xxxx@xxxx.iam.gserviceaccount.com
|
||||||
export GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
|
export GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
require 'googleauth'
|
||||||
|
require 'google/apis/drive_v3'
|
||||||
|
|
||||||
|
Drive = ::Google::Apis::DriveV3
|
||||||
|
drive = Drive::DriveService.new
|
||||||
|
|
||||||
|
# Auths with ENV vars:
|
||||||
|
# "GOOGLE_CLIENT_ID",
|
||||||
|
# "GOOGLE_CLIENT_EMAIL",
|
||||||
|
# "GOOGLE_ACCOUNT_TYPE",
|
||||||
|
# "GOOGLE_PRIVATE_KEY"
|
||||||
|
auth = ::Google::Auth::ServiceAccountCredentials
|
||||||
|
.make_creds(scope: 'https://www.googleapis.com/auth/drive')
|
||||||
|
drive.authorization = auth
|
||||||
|
|
||||||
|
list_files = drive.list_files()
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
### Storage
|
### Storage
|
||||||
|
|
||||||
Authorizers require a storage instance to manage long term persistence of
|
Authorizers require a storage instance to manage long term persistence of
|
||||||
|
|
Loading…
Reference in New Issue