Skip to content

Commit

Permalink
adjust URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
runtologist committed May 21, 2024
1 parent 8a97d45 commit e5c96ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
5 changes: 4 additions & 1 deletion vehicle/bluelink.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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=",
}
Expand Down
17 changes: 10 additions & 7 deletions vehicle/bluelink/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
type Config struct {
AuthURI string
APIURI string
RedirectPath string
AuthClientID string // v2
BrandAuthUrl string // v2
BasicToken string
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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"`
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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 {
Expand Down

0 comments on commit e5c96ac

Please sign in to comment.