Audi: fix authorization (#26591)
This commit is contained in:
parent
226fdac9bc
commit
4bead80886
5 changed files with 14 additions and 40 deletions
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/util"
|
||||
"github.com/evcc-io/evcc/util/request"
|
||||
"github.com/evcc-io/evcc/vehicle/audi/etron"
|
||||
"github.com/evcc-io/evcc/vehicle/audi"
|
||||
"github.com/evcc-io/evcc/vehicle/vag/idkproxy"
|
||||
"github.com/evcc-io/evcc/vehicle/vag/service"
|
||||
"github.com/evcc-io/evcc/vehicle/vag/vwidentity"
|
||||
|
|
@ -54,28 +54,28 @@ func NewAudiFromConfig(other map[string]any) (api.Vehicle, error) {
|
|||
log := util.NewLogger("audi").Redact(cc.User, cc.Password, cc.VIN)
|
||||
|
||||
// get initial VW identity id_token
|
||||
q, err := vwidentity.Login(log, etron.AuthParams, cc.User, cc.Password)
|
||||
q, err := vwidentity.Login(log, audi.AuthParams, cc.User, cc.Password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// exchange initial VW identity id_token for Audi AAZS token
|
||||
idk := idkproxy.New(log, etron.IDKParams)
|
||||
ats, its, err := service.AAZSTokenSource(log, idk, etron.AZSConfig, q)
|
||||
idk := idkproxy.New(log, audi.IDKParams)
|
||||
ats, its, err := service.AAZSTokenSource(log, idk, audi.AZSConfig, q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// use the etron API for list of vehicles
|
||||
api := etron.NewAPI(log, ats)
|
||||
api := audi.NewAPI(log, ats)
|
||||
|
||||
vehicle, err := ensureVehicleEx(
|
||||
cc.VIN, func() ([]etron.Vehicle, error) {
|
||||
cc.VIN, func() ([]audi.Vehicle, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), cc.Timeout)
|
||||
defer cancel()
|
||||
return api.Vehicles(ctx)
|
||||
},
|
||||
func(v etron.Vehicle) (string, error) {
|
||||
func(v audi.Vehicle) (string, error) {
|
||||
return v.VIN, nil
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package etron
|
||||
package audi
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package etron
|
||||
|
||||
import "net/url"
|
||||
|
||||
// Authorization parameters
|
||||
var AuthParams = url.Values{
|
||||
"response_type": {"code id_token token"},
|
||||
"client_id": {"f4d0934f-32bf-4ce4-b3c4-699a7049ad26@apps_vw-dilab_com"},
|
||||
"redirect_uri": {"myaudi:///"},
|
||||
"scope": {"openid profile mbb"}, // vin badge birthdate nickname email address phone name picture
|
||||
"prompt": {"login"},
|
||||
"ui_locales": {"de-DE"},
|
||||
}
|
||||
|
||||
var IDKParams = url.Values{
|
||||
"client_id": {"f4d0934f-32bf-4ce4-b3c4-699a7049ad26@apps_vw-dilab_com"},
|
||||
"redirect_uri": {"myaudi:///"},
|
||||
}
|
||||
|
||||
const AZSConfig = "myaudi"
|
||||
|
|
@ -2,18 +2,10 @@ package audi
|
|||
|
||||
import "net/url"
|
||||
|
||||
const (
|
||||
Brand = "Audi"
|
||||
Country = "DE"
|
||||
|
||||
// Authorization ClientID
|
||||
AuthClientID = "77869e21-e30a-4a92-b016-48ab7d3db1d8"
|
||||
)
|
||||
|
||||
// Authorization parameters
|
||||
var AuthParams = url.Values{
|
||||
"response_type": {"code id_token token"},
|
||||
"client_id": {"09b6cbec-cd19-4589-82fd-363dfa8c24da@apps_vw-dilab_com"},
|
||||
"response_type": {"code"},
|
||||
"client_id": {"f4d0934f-32bf-4ce4-b3c4-699a7049ad26@apps_vw-dilab_com"},
|
||||
"redirect_uri": {"myaudi:///"},
|
||||
"scope": {"openid profile mbb"}, // vin badge birthdate nickname email address phone name picture
|
||||
"prompt": {"login"},
|
||||
|
|
@ -21,6 +13,8 @@ var AuthParams = url.Values{
|
|||
}
|
||||
|
||||
var IDKParams = url.Values{
|
||||
"client_id": {"09b6cbec-cd19-4589-82fd-363dfa8c24da@apps_vw-dilab_com"},
|
||||
"client_id": {"f4d0934f-32bf-4ce4-b3c4-699a7049ad26@apps_vw-dilab_com"},
|
||||
"redirect_uri": {"myaudi:///"},
|
||||
}
|
||||
|
||||
const AZSConfig = "myaudi"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package etron
|
||||
package audi
|
||||
|
||||
type Vehicle struct {
|
||||
VIN, Type, Nickname string
|
||||
Loading…
Add table
Add a link
Reference in a new issue