Tweaks to rclone authorize

* Document the headless / remote setup procedure
  * Move Config constants into fs
  * Parse arguments in main for Authorize
This commit is contained in:
Nick Craig-Wood
2016-01-07 15:20:32 +00:00
parent bcbd30bb8a
commit 5189231a34
18 changed files with 159 additions and 66 deletions

View File

@@ -26,6 +26,18 @@ import (
const (
configFileName = ".rclone.conf"
// ConfigToken is the key used to store the token under
ConfigToken = "token"
// ConfigClientID is the config key used to store the client id
ConfigClientID = "client_id"
// ConfigClientSecret is the config key used to store the client secret
ConfigClientSecret = "client_secret"
// ConfigAutomatic indicates that we want non-interactive configuration
ConfigAutomatic = "config_automatic"
)
// SizeSuffix is parsed by flag with k/M/G suffixes
@@ -533,21 +545,13 @@ func EditConfig() {
}
}
// Duplicated from oauthutil to avoid circular reference.
const (
// ConfigClientID is the config key used to store the client id
ConfigClientID = "client_id"
// ConfigClientSecret is the config key used to store the client secret
ConfigClientSecret = "client_secret"
// ConfigAutomatic indicates that we want non-interactive configuration
ConfigAutomatic = "config_automatic"
)
// Authorize is for remote authorization of headless machines.
func Authorize() {
args := pflag.Args()[1:]
//
// It expects 1 or 3 arguments
//
// rclone authorize "fs name"
// rclone authorize "fs name" "client id" "client secret"
func Authorize(args []string) {
switch len(args) {
case 1, 3:
default:
@@ -560,7 +564,7 @@ func Authorize() {
}
if fs.Config == nil {
log.Fatalf("No configuration on fs %v", newType)
log.Fatalf("Can't authorize fs %q", newType)
}
// Name used for temporary fs
name := "**temp-fs**"