From 10535d4b4d35cd74636a763b688036321d9a41e8 Mon Sep 17 00:00:00 2001 From: andig Date: Tue, 22 Mar 2022 16:50:34 +0100 Subject: [PATCH] chore: simplify --- vehicle/bluelink/identity.go | 4 ++-- vehicle/bmw/identity.go | 30 +++++++++++++++--------------- vehicle/nissan/identity.go | 24 ++++++++++++------------ 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/vehicle/bluelink/identity.go b/vehicle/bluelink/identity.go index 4c145c98b..e19957780 100644 --- a/vehicle/bluelink/identity.go +++ b/vehicle/bluelink/identity.go @@ -64,11 +64,11 @@ func (v *Identity) getDeviceID() (string, error) { return "", err } - uniID, _ := uuid.NewUUID() + uuid := uuid.NewString() data := map[string]interface{}{ "pushRegId": "1", "pushType": "GCM", - "uuid": uniID.String(), + "uuid": uuid, } headers := map[string]string{ diff --git a/vehicle/bmw/identity.go b/vehicle/bmw/identity.go index 9c754f078..991dbfd8e 100644 --- a/vehicle/bmw/identity.go +++ b/vehicle/bmw/identity.go @@ -108,17 +108,17 @@ func (v *Identity) login() (*oauth2.Token, error) { } data := url.Values{ - "client_id": []string{"31c357a0-7a1d-4590-aa99-33b97244d048"}, - "response_type": []string{"code"}, - "redirect_uri": []string{RedirectURI}, - "state": []string{"cwU-gIE27j67poy2UcL3KQ"}, - "scope": []string{"authenticate_user vehicle_data remote_services"}, - "nonce": []string{"login_nonce"}, - "code_challenge_method": []string{"S256"}, - "code_challenge": []string{cv.CodeChallengeS256()}, - "username": []string{v.user}, - "password": []string{v.password}, - "grant_type": []string{"authorization_code"}, + "client_id": {"31c357a0-7a1d-4590-aa99-33b97244d048"}, + "response_type": {"code"}, + "redirect_uri": {RedirectURI}, + "state": {"cwU-gIE27j67poy2UcL3KQ"}, + "scope": {"authenticate_user vehicle_data remote_services"}, + "nonce": {"login_nonce"}, + "code_challenge_method": {"S256"}, + "code_challenge": {cv.CodeChallengeS256()}, + "username": {v.user}, + "password": {v.password}, + "grant_type": {"authorization_code"}, } uri := fmt.Sprintf("%s/authenticate", AuthURI) @@ -172,10 +172,10 @@ func (v *Identity) login() (*oauth2.Token, error) { } data = url.Values{ - "code": []string{query.Get("code")}, - "redirect_uri": []string{RedirectURI}, - "grant_type": []string{"authorization_code"}, - "code_verifier": []string{cv.CodeChallengePlain()}, + "code": {query.Get("code")}, + "redirect_uri": {RedirectURI}, + "grant_type": {"authorization_code"}, + "code_verifier": {cv.CodeChallengePlain()}, } return v.retrieveToken(data) diff --git a/vehicle/nissan/identity.go b/vehicle/nissan/identity.go index 21322c146..4f43aaf01 100644 --- a/vehicle/nissan/identity.go +++ b/vehicle/nissan/identity.go @@ -81,11 +81,11 @@ func (v *Identity) Login(user, password string) error { if err == nil { data := url.Values{ - "client_id": []string{ClientID}, - "redirect_uri": []string{RedirectURI}, - "response_type": []string{"code"}, - "scope": []string{Scope}, - "nonce": []string{"sdfdsfez"}, + "client_id": {ClientID}, + "redirect_uri": {RedirectURI}, + "response_type": {"code"}, + "scope": {Scope}, + "nonce": {"sdfdsfez"}, } uri := fmt.Sprintf("%s/oauth2/%s/authorize?%s", AuthBaseURL, realm, data.Encode()) @@ -108,11 +108,11 @@ func (v *Identity) Login(user, password string) error { var token oauth.Token if err == nil { data := url.Values{ - "code": []string{code}, - "client_id": []string{ClientID}, - "client_secret": []string{ClientSecret}, - "redirect_uri": []string{RedirectURI}, - "grant_type": []string{"authorization_code"}, + "code": {code}, + "client_id": {ClientID}, + "client_secret": {ClientSecret}, + "redirect_uri": {RedirectURI}, + "grant_type": {"authorization_code"}, } uri = fmt.Sprintf("%s/oauth2/%s/access_token?%s", AuthBaseURL, realm, data.Encode()) @@ -131,8 +131,8 @@ func (v *Identity) Login(user, password string) error { func (v *Identity) RefreshToken(token *oauth2.Token) (*oauth2.Token, error) { data := url.Values{ - "client_id": []string{ClientID}, - "client_secret": []string{ClientSecret}, + "client_id": {ClientID}, + "client_secret": {ClientSecret}, "grant_type": {"refresh_token"}, "refresh_token": {token.RefreshToken}, }