chore: simplify

This commit is contained in:
andig 2022-03-22 16:50:34 +01:00
parent c8a741a3e2
commit 10535d4b4d
3 changed files with 29 additions and 29 deletions

View file

@ -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{

View file

@ -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)

View file

@ -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},
}