mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 06:06:27 +08:00
lib/oauthutil: allow the browser opening function to be overridden
Some checks are pending
Docker beta build / Build image job (push) Waiting to run
Some checks are pending
Docker beta build / Build image job (push) Waiting to run
This commit is contained in:
parent
c527dd8c9c
commit
72f06bcc4b
|
@ -80,6 +80,11 @@ All done. Please go back to rclone.
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// OpenURL is used when rclone wants to open a browser window
|
||||||
|
// for user authentication. It defaults to something which
|
||||||
|
// should work for most uses, but may be overridden.
|
||||||
|
var OpenURL = open.Start
|
||||||
|
|
||||||
// SharedOptions are shared between backends the utilize an OAuth flow
|
// SharedOptions are shared between backends the utilize an OAuth flow
|
||||||
var SharedOptions = []fs.Option{{
|
var SharedOptions = []fs.Option{{
|
||||||
Name: config.ConfigClientID,
|
Name: config.ConfigClientID,
|
||||||
|
@ -716,8 +721,12 @@ func configSetup(ctx context.Context, id, name string, m configmap.Mapper, oauth
|
||||||
|
|
||||||
if !authorizeNoAutoBrowser {
|
if !authorizeNoAutoBrowser {
|
||||||
// Open the URL for the user to visit
|
// Open the URL for the user to visit
|
||||||
_ = open.Start(authURL)
|
err := OpenURL(authURL)
|
||||||
|
if err != nil {
|
||||||
|
fs.Errorf(nil, "Failed to open browser automatically (%v) - please go to the following link: %s\n", err, authURL)
|
||||||
|
} else {
|
||||||
fs.Logf(nil, "If your browser doesn't open automatically go to the following link: %s\n", authURL)
|
fs.Logf(nil, "If your browser doesn't open automatically go to the following link: %s\n", authURL)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fs.Logf(nil, "Please go to the following link: %s\n", authURL)
|
fs.Logf(nil, "Please go to the following link: %s\n", authURL)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user