mirror of
https://github.com/rclone/rclone.git
synced 2025-08-09 05:54:43 +02:00
fs: deglobalise the config #4685
This is done by making fs.Config private and attaching it to the context instead. The Config should be obtained with fs.GetConfig and fs.AddConfig should be used to get a new mutable config that can be changed.
This commit is contained in:
@ -353,7 +353,7 @@ func NewClientWithBaseClient(ctx context.Context, name string, m configmap.Mappe
|
||||
// NewClient gets a token from the config file and configures a Client
|
||||
// with it. It returns the client and a TokenSource which Invalidate may need to be called on
|
||||
func NewClient(ctx context.Context, name string, m configmap.Mapper, oauthConfig *oauth2.Config) (*http.Client, *TokenSource, error) {
|
||||
return NewClientWithBaseClient(ctx, name, m, oauthConfig, fshttp.NewClient(fs.Config))
|
||||
return NewClientWithBaseClient(ctx, name, m, oauthConfig, fshttp.NewClient(fs.GetConfig(ctx)))
|
||||
}
|
||||
|
||||
// AuthResult is returned from the web server after authorization
|
||||
@ -526,7 +526,7 @@ version recommended):
|
||||
}
|
||||
|
||||
// Exchange the code for a token
|
||||
ctx = Context(ctx, fshttp.NewClient(fs.Config))
|
||||
ctx = Context(ctx, fshttp.NewClient(fs.GetConfig(ctx)))
|
||||
token, err := oauthConfig.Exchange(ctx, auth.Code)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get token")
|
||||
|
Reference in New Issue
Block a user