8
"github.com/juju/webbrowser"
11
// OpenWebBrowser opens a web browser at the
12
// given URL. If the OS is not recognised, the URL
13
// is just printed to standard output.
14
func OpenWebBrowser(url *url.URL) error {
15
err := webbrowser.Open(url)
17
fmt.Fprintf(os.Stderr, "Opening an authorization web page in your browser.\n")
18
fmt.Fprintf(os.Stderr, "If it does not open, please open this URL:\n%s\n", url)
21
if err == webbrowser.ErrNoBrowser {
22
fmt.Fprintf(os.Stderr, "Please open this URL in your browser to authorize:\n%s\n", url)
28
// WebBrowserVisitor holds an interactor that supports the "Interactive"
29
// method by opening a web browser at the required location.
30
var WebBrowserVisitor Visitor = webBrowserVisitor{}
32
type webBrowserVisitor struct{}
34
func (webBrowserVisitor) VisitWebPage(client *Client, methodURLs map[string]*url.URL) error {
35
u := methodURLs[UserInteractionMethod]
37
return ErrMethodNotSupported
39
return OpenWebBrowser(u)