func (v *Identity) LoginSkoda(query url.Values, user, password string) error {
	login := func() (oauth.Token, error) {
		var token oauth.Token
		uri := fmt.Sprintf("%s/oidc/v1/authorize?%s", IdentityURI, query.Encode())

		q, err := v.login(uri, user, password)
		if err == nil {
			data := url.Values(map[string][]string{
				"auth_code": {q.Get("code")},
				"id_token":  {q.Get("id_token")},
				"brand":     {"skoda"},
			})

			var req *http.Request
			uri = fmt.Sprintf("%s/exchangeAuthCode", TokenServiceURI)
			req, err = request.New(http.MethodPost, uri, strings.NewReader(data.Encode()), request.URLEncoding)

			if err == nil {
				err = v.DoJSON(req, &token)
			}
		}

		return token, err
	}

	token, err := login()
	if err == nil {
		v.TokenSource = oauth.RefreshTokenSource((*oauth2.Token)(&token), skoda.Refresher(v.log, login))
	}

	return err
}
// LoginSkoda performs Skoda login and finally exchanges code and id token for access and refresh tokens
LoginSkoda performs Skoda login and finally exchanges code and id token for access and refresh tokens
// LoginSkoda performs Skoda login and finally exchanges code and id token for access and refresh tokens
func (v *Identity) LoginSkoda(query url.Values, user, password string) error {
	login := func() (oauth.Token, error) {
		var token oauth.Token
		uri := fmt.Sprintf("%s/oidc/v1/authorize?%s", IdentityURI, query.Encode())
		q, err := v.login(uri, user, password)
		if err == nil {
			data := url.Values(map[string][]string{
				"auth_code": {q.Get("code")},
				"id_token":  {q.Get("id_token")},
				"brand":     {"skoda"},
			})
			var req *http.Request
			uri = fmt.Sprintf("%s/exchangeAuthCode", TokenServiceURI)
			req, err = request.New(http.MethodPost, uri, strings.NewReader(data.Encode()), request.URLEncoding)
			if err == nil {
				err = v.DoJSON(req, &token)
			}
		}
		return token, err
	}
	token, err := login()
	if err == nil {
		v.TokenSource = oauth.RefreshTokenSource((*oauth2.Token)(&token), skoda.Refresher(v.log, login))
	}
	return err
}
func ( v * Identity ) LoginSkoda ( query url . Values , user , password string ) error { login := func ( ) ( oauth . Token , error ) { var token oauth . Token uri := fmt . Sprintf ( " " , IdentityURI , query . Encode ( ) ) q , err := v . login ( uri , user , password ) if err == nil { data := url . Values ( map [ string ] [ ] string { " " : { q . Get ( " " ) } , " " : { q . Get ( " " ) } , " " : { " " } , } ) var req * http . Request uri = fmt . Sprintf ( " " , TokenServiceURI ) req , err = request . New ( http . MethodPost , uri , strings . NewReader ( data . Encode ( ) ) , request . URLEncoding ) if err == nil { err = v . DoJSON ( req , & token ) } } return token , err } token , err := login ( ) if err == nil { v . TokenSource = oauth . RefreshTokenSource ( ( * oauth2 . Token ) ( & token ) , skoda . Refresher ( v . log , login ) ) } return err }
LoginSkoda performs Skoda login and finally exchanges code and id token for access and refresh tokens
LoginSkoda performs Skoda login and finally exchanges code and id token for access and refresh tokens