gcs: Don't configure the oauth token if service_account_file is supplied

This commit is contained in:
Nick Craig-Wood 2016-04-22 19:58:52 +01:00
parent 022ab4516d
commit 3a1198cac5
2 changed files with 7 additions and 15 deletions

View File

@ -160,21 +160,10 @@ creating an account, a JSON file containing the Service Account's
credentials will be downloaded onto your machines. These credentials credentials will be downloaded onto your machines. These credentials
are what rclone will use for authentication. are what rclone will use for authentication.
To use a Service Account instead of OAuth2 token flow, replace the To use a Service Account instead of OAuth2 token flow, enter the path
`token` section of your `.rclone.conf` with a `service_account_file` to your Service Account credentials at the `service_account_file`
pointing to the JSON credentials. prompt and rclone won't use the browser based authentication
flow.
For example, here's an example `.rclone.conf` that sets up read only
access using a service account:
```
[readonly-sync]
type = google cloud storage
project_number = 123456789
service_account_file = $HOME/.rclone-service_account.json
object_acl = authenticatedRead
bucket_acl = authenticatedRead
```
### Modified time ### ### Modified time ###

View File

@ -62,6 +62,9 @@ func init() {
Description: "Google Cloud Storage (this is not Google Drive)", Description: "Google Cloud Storage (this is not Google Drive)",
NewFs: NewFs, NewFs: NewFs,
Config: func(name string) { Config: func(name string) {
if fs.ConfigFile.MustValue(name, "service_account_file") != "" {
return
}
err := oauthutil.Config("google cloud storage", name, storageConfig) err := oauthutil.Config("google cloud storage", name, storageConfig)
if err != nil { if err != nil {
log.Fatalf("Failed to configure token: %v", err) log.Fatalf("Failed to configure token: %v", err)