mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 23:49:15 +01:00
onedrive: Add option to choose resourceURL during setup of OneDrive Business account if more than one is avauilable for user
This commit is contained in:
parent
245edd1b0e
commit
682b4d54c5
@ -135,25 +135,31 @@ func init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
foundService := ""
|
var resourcesURL []string
|
||||||
|
var resourcesID []string
|
||||||
|
|
||||||
for _, service := range services.Services {
|
for _, service := range services.Services {
|
||||||
if service.ServiceAPIVersion == "v2.0" {
|
if service.ServiceAPIVersion == "v2.0" {
|
||||||
foundService = service.ServiceResourceID
|
resourcesID = append(resourcesID, service.ServiceResourceID)
|
||||||
fs.ConfigFileSet(name, configResourceURL, foundService)
|
resourcesURL = append(resourcesURL, service.ServiceEndpointURI)
|
||||||
oauthBusinessResource = oauth2.SetAuthURLParam("resource", foundService)
|
|
||||||
|
|
||||||
fs.Logf(nil, "Found API %s endpoint %s", service.ServiceAPIVersion, service.ServiceEndpointURI)
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
// we only support 2.0 API
|
// we only support 2.0 API
|
||||||
fs.Infof(nil, "Skipping API %s endpoint %s", service.ServiceAPIVersion, service.ServiceEndpointURI)
|
fs.Infof(nil, "Skipping API %s endpoint %s", service.ServiceAPIVersion, service.ServiceEndpointURI)
|
||||||
}
|
}
|
||||||
|
|
||||||
if foundService == "" {
|
var foundService string
|
||||||
|
if len(resourcesID) == 0 {
|
||||||
fs.Errorf(nil, "No Service found")
|
fs.Errorf(nil, "No Service found")
|
||||||
return
|
return
|
||||||
|
} else if len(resourcesID) == 1 {
|
||||||
|
foundService = resourcesID[0]
|
||||||
|
} else {
|
||||||
|
foundService = fs.Choose("Choose resource URL", resourcesID, resourcesURL, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.ConfigFileSet(name, configResourceURL, foundService)
|
||||||
|
oauthBusinessResource = oauth2.SetAuthURLParam("resource", foundService)
|
||||||
|
|
||||||
// get the token from the inital config
|
// get the token from the inital config
|
||||||
// we need to update the token with a resource
|
// we need to update the token with a resource
|
||||||
// specific token we will query now
|
// specific token we will query now
|
||||||
|
Loading…
Reference in New Issue
Block a user