mirror of
https://github.com/rclone/rclone.git
synced 2025-07-16 22:42:36 +02:00
Direct support for dropbox's impersonate memberid
By optionally using the new `impersonate_id` flag we can avoid an unnecessary API call fetching the ID for member email/username
This commit is contained in:
@ -137,8 +137,10 @@ var (
|
|||||||
// Gets an oauth config with the right scopes
|
// Gets an oauth config with the right scopes
|
||||||
func getOauthConfig(m configmap.Mapper) *oauthutil.Config {
|
func getOauthConfig(m configmap.Mapper) *oauthutil.Config {
|
||||||
// If not impersonating, use standard scopes
|
// If not impersonating, use standard scopes
|
||||||
if impersonate, _ := m.Get("impersonate"); impersonate == "" {
|
impersonate, _ := m.Get("impersonate")
|
||||||
return dropboxConfig
|
impersonateID, _ := m.Get("impersonate_id")
|
||||||
|
if impersonate == "" && impersonateID == "" {
|
||||||
|
return dropboxConfig // Default config if neither is set
|
||||||
}
|
}
|
||||||
// Make a copy of the config
|
// Make a copy of the config
|
||||||
config := *dropboxConfig
|
config := *dropboxConfig
|
||||||
@ -255,6 +257,7 @@ folders.`,
|
|||||||
type Options struct {
|
type Options struct {
|
||||||
ChunkSize fs.SizeSuffix `config:"chunk_size"`
|
ChunkSize fs.SizeSuffix `config:"chunk_size"`
|
||||||
Impersonate string `config:"impersonate"`
|
Impersonate string `config:"impersonate"`
|
||||||
|
ImpersonateID string `config:"impersonate_id"`
|
||||||
SharedFiles bool `config:"shared_files"`
|
SharedFiles bool `config:"shared_files"`
|
||||||
SharedFolders bool `config:"shared_folders"`
|
SharedFolders bool `config:"shared_folders"`
|
||||||
BatchMode string `config:"batch_mode"`
|
BatchMode string `config:"batch_mode"`
|
||||||
@ -430,7 +433,9 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
|||||||
// NOTE: needs to be created pre-impersonation so we can look up the impersonated user
|
// NOTE: needs to be created pre-impersonation so we can look up the impersonated user
|
||||||
f.team = team.New(cfg)
|
f.team = team.New(cfg)
|
||||||
|
|
||||||
if opt.Impersonate != "" {
|
if opt.ImpersonateID != "" {
|
||||||
|
cfg.AsMemberID = opt.ImpersonateID
|
||||||
|
} else if opt.Impersonate != "" {
|
||||||
user := team.UserSelectorArg{
|
user := team.UserSelectorArg{
|
||||||
Email: opt.Impersonate,
|
Email: opt.Impersonate,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user