mirror of
https://github.com/rclone/rclone.git
synced 2025-01-24 12:56: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:
parent
6a217c7dc1
commit
9ea2169df2
@ -137,8 +137,10 @@ var (
|
||||
// Gets an oauth config with the right scopes
|
||||
func getOauthConfig(m configmap.Mapper) *oauthutil.Config {
|
||||
// If not impersonating, use standard scopes
|
||||
if impersonate, _ := m.Get("impersonate"); impersonate == "" {
|
||||
return dropboxConfig
|
||||
impersonate, _ := m.Get("impersonate")
|
||||
impersonateID, _ := m.Get("impersonate_id")
|
||||
if impersonate == "" && impersonateID == "" {
|
||||
return dropboxConfig // Default config if neither is set
|
||||
}
|
||||
// Make a copy of the config
|
||||
config := *dropboxConfig
|
||||
@ -255,6 +257,7 @@ folders.`,
|
||||
type Options struct {
|
||||
ChunkSize fs.SizeSuffix `config:"chunk_size"`
|
||||
Impersonate string `config:"impersonate"`
|
||||
ImpersonateID string `config:"impersonate_id"`
|
||||
SharedFiles bool `config:"shared_files"`
|
||||
SharedFolders bool `config:"shared_folders"`
|
||||
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
|
||||
f.team = team.New(cfg)
|
||||
|
||||
if opt.Impersonate != "" {
|
||||
if opt.ImpersonateID != "" {
|
||||
cfg.AsMemberID = opt.ImpersonateID
|
||||
} else if opt.Impersonate != "" {
|
||||
user := team.UserSelectorArg{
|
||||
Email: opt.Impersonate,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user