1
mirror of https://github.com/rclone/rclone synced 2024-11-27 05:23:40 +01:00

onedrive: fix failed to configure: empty token found error #3455

This bug was caused as part of the config rework
This commit is contained in:
Nick Craig-Wood 2021-05-17 10:00:54 +01:00
parent 03229cf394
commit 6555d3eb33

View File

@ -371,15 +371,9 @@ func chooseDrive(ctx context.Context, name string, m configmap.Mapper, srv *rest
// Config the backend
func Config(ctx context.Context, name string, m configmap.Mapper, config fs.ConfigIn) (*fs.ConfigOut, error) {
oAuthClient, _, err := oauthutil.NewClient(ctx, name, m, oauthConfig)
if err != nil {
return nil, errors.Wrap(err, "failed to configure OneDrive")
}
srv := rest.NewClient(oAuthClient)
region, graphURL := getRegionURL(m)
switch config.State {
case "":
if config.State == "" {
oauthConfig.Endpoint = oauth2.Endpoint{
AuthURL: authEndpoint[region] + authPath,
TokenURL: authEndpoint[region] + tokenPath,
@ -387,6 +381,15 @@ func Config(ctx context.Context, name string, m configmap.Mapper, config fs.Conf
return oauthutil.ConfigOut("choose_type", &oauthutil.Options{
OAuth2Config: oauthConfig,
})
}
oAuthClient, _, err := oauthutil.NewClient(ctx, name, m, oauthConfig)
if err != nil {
return nil, errors.Wrap(err, "failed to configure OneDrive")
}
srv := rest.NewClient(oAuthClient)
switch config.State {
case "choose_type":
return fs.ConfigChooseFixed("choose_type_done", "config_type", "Type of connection", []fs.OptionExample{{
Value: "onedrive",