From e5c96ac78c648eafa7840692a4cd273899ae8ebd Mon Sep 17 00:00:00 2001 From: Simon Schenk Date: Thu, 16 May 2024 14:56:58 +0200 Subject: [PATCH] adjust URLs --- vehicle/bluelink.go | 5 ++++- vehicle/bluelink/identity.go | 17 ++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/vehicle/bluelink.go b/vehicle/bluelink.go index 1dc6739330..3c09e9b096 100644 --- a/vehicle/bluelink.go +++ b/vehicle/bluelink.go @@ -28,6 +28,7 @@ func NewHyundaiFromConfig(other map[string]interface{}) (api.Vehicle, error) { settings := bluelink.Config{ AuthURI: "https://prd.eu-ccapi.hyundai.com:8080", APIURI: "https://prd.eu-ccapi.hyundai.com:8080", + RedirectPath: "/api/v1/user/oauth2/redirect", BasicToken: "NmQ0NzdjMzgtM2NhNC00Y2YzLTk1NTctMmExOTI5YTk0NjU0OktVeTQ5WHhQekxwTHVvSzB4aEJDNzdXNlZYaG10UVI5aVFobUlGampvWTRJcHhzVg==", CCSPServiceID: "6d477c38-3ca4-4cf3-9557-2a1929a94654", CCSPApplicationID: bluelink.HyundaiAppID, @@ -45,6 +46,7 @@ func NewKiaFromConfig(other map[string]interface{}) (api.Vehicle, error) { settings := bluelink.Config{ AuthURI: "https://prd.eu-ccapi.kia.com:8080", APIURI: "https://prd.eu-ccapi.kia.com:8080", + RedirectPath: "/api/v1/user/oauth2/redirect", BasicToken: "ZmRjODVjMDAtMGEyZi00YzY0LWJjYjQtMmNmYjE1MDA3MzBhOnNlY3JldA==", CCSPServiceID: "fdc85c00-0a2f-4c64-bcb4-2cfb1500730a", CCSPApplicationID: bluelink.KiaAppID, @@ -62,11 +64,12 @@ func NewGenesisFromConfig(other map[string]interface{}) (api.Vehicle, error) { settings := bluelink.Config{ AuthURI: "https://accounts-eu.genesis.com", APIURI: "https://prd-eu-ccapi.genesis.com", + RedirectPath: "/realms/eugenesisidm/ga-api/redirect2", BasicToken: "NmQ0NzdjMzgtM2NhNC00Y2YzLTk1NTctMmExOTI5YTk0NjU0OktVeTQ5WHhQekxwTHVvSzB4aEJDNzdXNlZYaG10UVI5aVFobUlGampvWTRJcHhzVg==", CCSPServiceID: "3020afa2-30ff-412a-aa51-d28fbe901e10", CCSPApplicationID: bluelink.GenesisAppID, AuthClientID: "f11f2b86-e0e7-4851-90df-5600b01d8b70", - BrandAuthUrl: "https://accounts-eu.genesis.com/auth/realms/eukiaidm/protocol/openid-connect/auth?client_id=%s&scope=openid+profile+email+phone&response_type=code&hkid_session_reset=true&redirect_uri=%s/api/v1/user/integration/redirect/login&ui_locales=%s&state=%s:%s", + BrandAuthUrl: "https://accounts-eu.genesis.com/realms/eugenesisidm/protocol/openid-connect/auth?client_id=%s&scope=openid+profile+email+phone&response_type=code&hkid_session_reset=true&redirect_uri=%s/api/v1/user/integration/redirect/login&ui_locales=%s&state=%s:%s", PushType: "GCM", Cfb: "RFtoRq/vDXJmRndoZaZQyYo3/qFLtVReW8P7utRPcc0ZxOzOELm9mexvviBk/qqIp4A=", } diff --git a/vehicle/bluelink/identity.go b/vehicle/bluelink/identity.go index e23e8564f2..3d417c922b 100644 --- a/vehicle/bluelink/identity.go +++ b/vehicle/bluelink/identity.go @@ -35,6 +35,7 @@ const ( type Config struct { AuthURI string APIURI string + RedirectPath string AuthClientID string // v2 BrandAuthUrl string // v2 BasicToken string @@ -114,7 +115,7 @@ func (v *Identity) getCookies() (cookieClient *request.Helper, err error) { uri := fmt.Sprintf( "%s/api/v1/user/oauth2/authorize?response_type=code&state=test&client_id=%s&redirect_uri=%s/api/v1/user/oauth2/redirect", - v.config.AuthURI, + v.config.APIURI, v.config.CCSPServiceID, v.config.AuthURI, ) @@ -144,7 +145,7 @@ func (v *Identity) setLanguage(cookieClient *request.Helper, language string) er } func (v *Identity) brandLogin(cookieClient *request.Helper, user, password string) (string, error) { - req, err := request.New(http.MethodGet, v.config.AuthURI+IntegrationInfoURL, nil, request.JSONEncoding) + req, err := request.New(http.MethodGet, v.config.APIURI+IntegrationInfoURL, nil, request.JSONEncoding) var info struct { UserId string `json:"userId"` @@ -159,7 +160,7 @@ func (v *Identity) brandLogin(cookieClient *request.Helper, user, password strin var resp *http.Response if err == nil { - uri := fmt.Sprintf(v.config.BrandAuthUrl, v.config.AuthClientID, v.config.AuthURI, "en", info.ServiceId, info.UserId) + uri := fmt.Sprintf(v.config.BrandAuthUrl, v.config.AuthClientID, v.config.APIURI, "en", info.ServiceId, info.UserId) req, err = request.New(http.MethodGet, uri, nil) if err == nil { @@ -253,7 +254,7 @@ func (v *Identity) bluelinkLogin(cookieClient *request.Helper, user, password st "password": password, } - req, err := request.New(http.MethodPost, v.config.AuthURI+LoginURL, request.MarshalJSON(data), request.JSONEncoding) + req, err := request.New(http.MethodPost, v.config.APIURI+LoginURL, request.MarshalJSON(data), request.JSONEncoding) if err != nil { return "", err } @@ -285,13 +286,14 @@ func (v *Identity) exchangeCode(accCode string) (oauth.Token, error) { data := url.Values{ "grant_type": {"authorization_code"}, - "redirect_uri": {v.config.AuthURI + "/api/v1/user/oauth2/redirect"}, + "redirect_uri": {v.config.AuthURI + v.config.RedirectPath}, "code": {accCode}, + "client_id": {v.config.CCSPServiceID}, } var token oauth.Token - req, err := request.New(http.MethodPost, v.config.AuthURI+TokenURL, strings.NewReader(data.Encode()), headers) + req, err := request.New(http.MethodPost, v.config.APIURI+TokenURL, strings.NewReader(data.Encode()), headers) if err == nil { err = v.DoJSON(req, &token) } @@ -311,9 +313,10 @@ func (v *Identity) RefreshToken(token *oauth2.Token) (*oauth2.Token, error) { "grant_type": {"refresh_token"}, "redirect_uri": {"https://www.getpostman.com/oauth2/callback"}, "refresh_token": {token.RefreshToken}, + "client_id": {v.config.CCSPServiceID}, } - req, err := request.New(http.MethodPost, v.config.AuthURI+TokenURL, strings.NewReader(data.Encode()), headers) + req, err := request.New(http.MethodPost, v.config.APIURI+TokenURL, strings.NewReader(data.Encode()), headers) var res oauth.Token if err == nil {