chore: minor

This commit is contained in:
andig 2025-11-22 17:15:40 +01:00
parent e1a8e1a524
commit befe06249c
5 changed files with 9 additions and 9 deletions

View file

@ -22,7 +22,7 @@ import (
)
func init() {
registry.AddCtx("oauth", NewOauthFromConfig)
registry.AddCtx("oauth", NewOAuthFromConfig)
}
var (
@ -55,7 +55,7 @@ type OAuth struct {
tokenStorer func(*oauth2.Token) any
}
func NewOauthFromConfig(ctx context.Context, other map[string]any) (oauth2.TokenSource, error) {
func NewOAuthFromConfig(ctx context.Context, other map[string]any) (oauth2.TokenSource, error) {
var cc struct {
Name, Device string
oauth2.Config `mapstructure:",squash"`
@ -65,13 +65,13 @@ func NewOauthFromConfig(ctx context.Context, other map[string]any) (oauth2.Token
return nil, err
}
return NewOauth(ctx, cc.Name, cc.Device, &cc.Config)
return NewOAuth(ctx, cc.Name, cc.Device, &cc.Config)
}
var _ api.AuthProvider = (*OAuth)(nil)
var _ oauth2.TokenSource = (*OAuth)(nil)
func NewOauth(ctx context.Context, name, device string, oc *oauth2.Config, opts ...func(o *OAuth)) (*OAuth, error) {
func NewOAuth(ctx context.Context, name, device string, oc *oauth2.Config, opts ...func(o *OAuth)) (*OAuth, error) {
if name == "" {
return nil, errors.New("instance name must not be empty")
}

View file

@ -46,5 +46,5 @@ func NewViessmannFromConfig(ctx context.Context, other map[string]any) (oauth2.T
return nil, err
}
return NewOauth(ctx, "Viessmann", cc.Gateway, &oc)
return NewOAuth(ctx, "Viessmann", cc.Gateway, &oc)
}

View file

@ -43,7 +43,7 @@ func OAuthConfig(clientId string) *oauth2.Config {
func NewOAuth(clientId, title string) (oauth2.TokenSource, error) {
oc := OAuthConfig(clientId)
return auth.NewOauth(context.Background(), "BMW/Mini", title, oc,
return auth.NewOAuth(context.Background(), "BMW/Mini", title, oc,
auth.WithOauthDeviceFlowOption(),
auth.WithTokenRetrieverOption(func(data string, res *oauth2.Token) error {
var token Token

View file

@ -31,7 +31,7 @@ var loginHeaders = map[string]string{
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1",
}
func NewOauth2Config(domain string) *oauth2.Config {
func OAuth2Config(domain string) *oauth2.Config {
uri := loginUri(domain)
return &oauth2.Config{
ClientID: ClientID,
@ -80,7 +80,7 @@ func (v *Identity) Login() error {
// login authenticates with username/password to get new token
func (v *Identity) login() (*oauth2.Token, error) {
oc := NewOauth2Config(v.domain)
oc := OAuth2Config(v.domain)
cv := oauth2.GenerateVerifier()
state := lo.RandomString(16, lo.AlphanumericCharset)

View file

@ -46,5 +46,5 @@ func OAuthConfig(id, secret, redirectUri string) *oauth2.Config {
}
func NewOAuth(oc *oauth2.Config, title string) (oauth2.TokenSource, error) {
return auth.NewOauth(context.Background(), "Volvo", title, oc)
return auth.NewOAuth(context.Background(), "Volvo", title, oc)
}