func (oa *Flow) DetectFlow() (*api.AccessToken, error) {
	accessToken, err := oa.DeviceFlow()
	if errors.Is(err, device.ErrUnsupported) {
		return oa.WebAppFlow()
	}
	return accessToken, err
}
DetectFlow tries to perform Device flow first and falls back to Web application flow.
package oauth
import (
	"errors"
	"fmt"
	"io"
	"net/http"
	"net/url"
	"github.com/cli/oauth/api"
	"github.com/cli/oauth/device"
)
type httpClient interface {
	PostForm(string, url.Values) (*http.Response, error)
}
type Host struct {
	DeviceCodeURL string
	AuthorizeURL  string
	TokenURL      string
}
func GitHubHost(hostURL string) *Host {
	u, _ := url.Parse(hostURL)
	return &Host{
		DeviceCodeURL: fmt.Sprintf("%s://%s/login/device/code", u.Scheme, u.Host),
		AuthorizeURL:  fmt.Sprintf("%s://%s/login/oauth/authorize", u.Scheme, u.Host),
		TokenURL:      fmt.Sprintf("%s://%s/login/oauth/access_token", u.Scheme, u.Host),
	}
}
type Flow struct {
	Hostname string
	Host *Host
	Scopes []string
	ClientID string
	ClientSecret string
	CallbackURI string
	DisplayCode func(string, string) error
	BrowseURL func(string) error
	WriteSuccessHTML func(io.Writer)
	HTTPClient httpClient
	Stdin io.Reader
	Stdout io.Writer
}