mirror of
https://github.com/rclone/rclone.git
synced 2025-01-01 20:09:48 +01:00
oauthutil: add scopes to token exchange for onedrive
See: https://forum.rclone.org/t/onedrive-config-auth-failure-body-must-contain-scope/32230/7
This commit is contained in:
parent
df513ca90a
commit
74a0800a4c
@ -677,7 +677,11 @@ func configSetup(ctx context.Context, id, name string, m configmap.Mapper, oauth
|
||||
// Exchange the code for a token
|
||||
func configExchange(ctx context.Context, name string, m configmap.Mapper, oauthConfig *oauth2.Config, code string) error {
|
||||
ctx = Context(ctx, fshttp.NewClient(ctx))
|
||||
token, err := oauthConfig.Exchange(ctx, code)
|
||||
var opts []oauth2.AuthCodeOption
|
||||
if len(oauthConfig.Scopes) > 0 {
|
||||
opts = append(opts, oauth2.SetAuthURLParam("scope", strings.Join(oauthConfig.Scopes, " ")))
|
||||
}
|
||||
token, err := oauthConfig.Exchange(ctx, code, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get token: %w", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user