Skip to content

Commit

Permalink
Hyundai: fix registration id (#8766)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Jul 3, 2023
1 parent 61c730b commit a249c86
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions vehicle/bluelink/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/evcc-io/evcc/util/oauth"
"github.com/evcc-io/evcc/util/request"
"github.com/google/uuid"
"github.com/samber/lo"
"golang.org/x/net/publicsuffix"
"golang.org/x/oauth2"
)
Expand Down Expand Up @@ -66,7 +67,7 @@ func (v *Identity) getDeviceID() (string, error) {

uuid := uuid.NewString()
data := map[string]interface{}{
"pushRegId": "1",
"pushRegId": lo.RandomString(64, []rune("0123456789ABCDEF")),
"pushType": "GCM",
"uuid": uuid,
}
Expand All @@ -79,7 +80,7 @@ func (v *Identity) getDeviceID() (string, error) {
"Stamp": stamp,
}

var resp struct {
var res struct {
RetCode string
ResMsg struct {
DeviceID string
Expand All @@ -88,10 +89,14 @@ func (v *Identity) getDeviceID() (string, error) {

req, err := request.New(http.MethodPost, v.config.URI+DeviceIdURL, request.MarshalJSON(data), headers)
if err == nil {
err = v.DoJSON(req, &resp)
err = v.DoJSON(req, &res)
}

if res.ResMsg.DeviceID == "" {
err = errors.New("deviceid not found")
}

return resp.ResMsg.DeviceID, err
return res.ResMsg.DeviceID, err
}

func (v *Identity) getCookies() (cookieClient *request.Helper, err error) {
Expand Down

0 comments on commit a249c86

Please sign in to comment.