mirror of
https://github.com/rclone/rclone.git
synced 2026-01-07 11:03:15 +00:00
authorize: add support for custom templates
This adds support for providing custom Go templates for use in the `rclone authorize` command. Fixes #6741
This commit is contained in:
committed by
GitHub
parent
745c0af571
commit
56b582cdb9
@@ -15,7 +15,7 @@ import (
|
||||
// rclone authorize "fs name"
|
||||
// rclone authorize "fs name" "base64 encoded JSON blob"
|
||||
// rclone authorize "fs name" "client id" "client secret"
|
||||
func Authorize(ctx context.Context, args []string, noAutoBrowser bool) error {
|
||||
func Authorize(ctx context.Context, args []string, noAutoBrowser bool, templateFile string) error {
|
||||
ctx = suppressConfirm(ctx)
|
||||
ctx = fs.ConfigOAuthOnly(ctx)
|
||||
switch len(args) {
|
||||
@@ -41,6 +41,11 @@ func Authorize(ctx context.Context, args []string, noAutoBrowser bool) error {
|
||||
inM[ConfigAuthNoBrowser] = "true"
|
||||
}
|
||||
|
||||
// Indicate if we specified a custom template via a file
|
||||
if templateFile != "" {
|
||||
inM[ConfigTemplateFile] = templateFile
|
||||
}
|
||||
|
||||
// Add extra parameters if supplied
|
||||
if len(args) == 2 {
|
||||
err := inM.Decode(args[1])
|
||||
|
||||
@@ -58,6 +58,12 @@ const (
|
||||
|
||||
// ConfigAuthNoBrowser indicates that we do not want to open browser
|
||||
ConfigAuthNoBrowser = "config_auth_no_browser"
|
||||
|
||||
// ConfigTemplate is the template content to be used in the authorization webserver
|
||||
ConfigTemplate = "config_template"
|
||||
|
||||
// ConfigTemplateFile is the path to a template file to read into the value of `ConfigTemplate` above
|
||||
ConfigTemplateFile = "config_template_file"
|
||||
)
|
||||
|
||||
// Storage defines an interface for loading and saving config to
|
||||
|
||||
Reference in New Issue
Block a user