forked from TrueCloudLab/rclone
parent
68333d34a1
commit
1e88f0702a
2 changed files with 16 additions and 2 deletions
|
@ -75,7 +75,7 @@ func init() {
|
||||||
Description: "Dropbox",
|
Description: "Dropbox",
|
||||||
NewFs: NewFs,
|
NewFs: NewFs,
|
||||||
Config: func(name string) {
|
Config: func(name string) {
|
||||||
err := oauthutil.Config("dropbox", name, dropboxConfig)
|
err := oauthutil.ConfigNoOffline("dropbox", name, dropboxConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to configure token: %v", err)
|
log.Fatalf("Failed to configure token: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,6 +250,16 @@ func NewClient(name string, config *oauth2.Config) (*http.Client, *TokenSource,
|
||||||
//
|
//
|
||||||
// It may run an internal webserver to receive the results
|
// It may run an internal webserver to receive the results
|
||||||
func Config(id, name string, config *oauth2.Config) error {
|
func Config(id, name string, config *oauth2.Config) error {
|
||||||
|
return doConfig(id, name, config, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfigNoOffline does the same as Config but does not pass the
|
||||||
|
// "access_type=offline" parameter.
|
||||||
|
func ConfigNoOffline(id, name string, config *oauth2.Config) error {
|
||||||
|
return doConfig(id, name, config, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func doConfig(id, name string, config *oauth2.Config, offline bool) error {
|
||||||
config, changed := overrideCredentials(name, config)
|
config, changed := overrideCredentials(name, config)
|
||||||
automatic := fs.ConfigFileGet(name, fs.ConfigAutomatic) != ""
|
automatic := fs.ConfigFileGet(name, fs.ConfigAutomatic) != ""
|
||||||
|
|
||||||
|
@ -322,7 +332,11 @@ func Config(id, name string, config *oauth2.Config) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
state := fmt.Sprintf("%x", stateBytes)
|
state := fmt.Sprintf("%x", stateBytes)
|
||||||
authURL := config.AuthCodeURL(state, oauth2.AccessTypeOffline)
|
var opts []oauth2.AuthCodeOption
|
||||||
|
if offline {
|
||||||
|
opts = append(opts, oauth2.AccessTypeOffline)
|
||||||
|
}
|
||||||
|
authURL := config.AuthCodeURL(state, opts...)
|
||||||
|
|
||||||
// Prepare webserver
|
// Prepare webserver
|
||||||
server := authServer{
|
server := authServer{
|
||||||
|
|
Loading…
Add table
Reference in a new issue