"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
authorize: refactor to use new config interfaces #5178
Nick Craig-Woodb9fd02039baa
diff --git a/fs/config/authorize.go b/fs/config/authorize.goindex dbdcccefa..404b5af5d 100644--- a/fs/config/authorize.go+++ b/fs/config/authorize.go@@ -2,9 +2,11 @@ package configimport ("context"+ "fmt""github.com/pkg/errors""github.com/rclone/rclone/fs"+ "github.com/rclone/rclone/fs/config/configmap")// Authorize is for remote authorization of headless machines.@@ -20,29 +22,43 @@ func Authorize(ctx context.Context, args []string, noAutoBrowser bool) error {default:return errors.Errorf("invalid number of arguments: %d", len(args))}- newType := args[0]- f := fs.MustFind(newType)- if f.Config == nil {- return errors.Errorf("can't authorize fs %q", newType)+ Type := args[0] // FIXME could read this from input+ ri, err := fs.Find(Type)+ if err != nil {+ return err+ }+ if ri.Config == nil {+ return errors.Errorf("can't authorize fs %q", Type)}- // Name used for temporary fs- name := "**temp-fs**"- // Make sure we delete it- defer DeleteRemote(name)+ // Config map for remote+ inM := configmap.Simple{}// Indicate that we are running rclone authorize- Data.SetValue(name, ConfigAuthorize, "true")+ inM[ConfigAuthorize] = "true"if noAutoBrowser {- Data.SetValue(name, ConfigAuthNoBrowser, "true")+ inM[ConfigAuthNoBrowser] = "true"}if len(args) == 3 {- Data.SetValue(name, ConfigClientID, args[1])- Data.SetValue(name, ConfigClientSecret, args[2])+ inM[ConfigClientID] = args[1]+ inM[ConfigClientSecret] = args[2]}- m := fs.ConfigMap(f, name, nil)- f.Config(ctx, name, m)+ // Name used for temporary remote+ name := "**temp-fs**"++ m := fs.ConfigMap(ri, name, inM)+ outM := configmap.Simple{}+ m.ClearSetters()+ m.AddSetter(outM)++ ri.Config(ctx, name, m)++ // Print code if we are doing a manual auth+ fmt.Printf("Paste the following into your remote machine --->\n%s\n<---End paste\n", outM["token"])++ fs.Debugf(nil, "Set parameters %q", outM)+return nil}diff --git a/lib/oauthutil/oauthutil.go b/lib/oauthutil/oauthutil.goindex d04aed11f..667d1645c 100644--- a/lib/oauthutil/oauthutil.go+++ b/lib/oauthutil/oauthutil.go@@ -526,14 +526,6 @@ version recommended):return errors.Wrap(err, "failed to get token")}- // Print code if we are doing a manual auth- if authorizeOnly {- result, err := json.Marshal(token)- if err != nil {- return errors.Wrap(err, "failed to marshal token")- }- fmt.Printf("Paste the following into your remote machine --->\n%s\n<---End paste\n", result)- }return PutToken(name, m, token, true)}