diff --git a/plugin/auth/oauth.go b/plugin/auth/oauth.go index 2bba2d26e..fec95e0a4 100644 --- a/plugin/auth/oauth.go +++ b/plugin/auth/oauth.go @@ -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") } diff --git a/plugin/auth/viessmann.go b/plugin/auth/viessmann.go index 89caad8b7..9343acdb8 100644 --- a/plugin/auth/viessmann.go +++ b/plugin/auth/viessmann.go @@ -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) } diff --git a/vehicle/bmw/cardata/oauth2.go b/vehicle/bmw/cardata/oauth2.go index ce617bdfc..0d6f620d2 100644 --- a/vehicle/bmw/cardata/oauth2.go +++ b/vehicle/bmw/cardata/oauth2.go @@ -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 diff --git a/vehicle/ford/identity.go b/vehicle/ford/identity.go index 3dd93e48d..b01b37b5d 100644 --- a/vehicle/ford/identity.go +++ b/vehicle/ford/identity.go @@ -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) diff --git a/vehicle/volvo/connected/oauth2.go b/vehicle/volvo/connected/oauth2.go index 06788c124..07d68eba6 100644 --- a/vehicle/volvo/connected/oauth2.go +++ b/vehicle/volvo/connected/oauth2.go @@ -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) }