func (v *Identity) LoginVAG(clientID string, 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{
				"grant_type": {"id_token"},
				"scope":      {"sc2:fal"},
				"token":      {q.Get("id_token")},
			})

			var req *http.Request
			req, err = request.New(http.MethodPost, OauthTokenURI, strings.NewReader(data.Encode()), map[string]string{
				"Content-Type": "application/x-www-form-urlencoded",
				"X-Client-Id":  clientID,
			})

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

		return token, err
	}

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

	return err
}
// LoginVAG performs VAG login and finally exchanges id token for access and refresh tokens
LoginVAG performs VAG login and finally exchanges id token for access and refresh tokens
// LoginVAG performs VAG login and finally exchanges id token for access and refresh tokens
func (v *Identity) LoginVAG(clientID string, 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{
				"grant_type": {"id_token"},
				"scope":      {"sc2:fal"},
				"token":      {q.Get("id_token")},
			})
			var req *http.Request
			req, err = request.New(http.MethodPost, OauthTokenURI, strings.NewReader(data.Encode()), map[string]string{
				"Content-Type": "application/x-www-form-urlencoded",
				"X-Client-Id":  clientID,
			})
			if err == nil {
				err = v.DoJSON(req, &token)
			}
		}
		return token, err
	}
	token, err := login()
	if err == nil {
		v.TokenSource = oauth.RefreshTokenSource((*oauth2.Token)(&token), Refresher(v.log, login, clientID))
	}
	return err
}
func ( v * Identity ) LoginVAG ( clientID string , 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 ( " " ) } , } ) var req * http . Request req , err = request . New ( http . MethodPost , OauthTokenURI , strings . NewReader ( data . Encode ( ) ) , map [ string ] string { " " : " " , " " : clientID , } ) if err == nil { err = v . DoJSON ( req , & token ) } } return token , err } token , err := login ( ) if err == nil { v . TokenSource = oauth . RefreshTokenSource ( ( * oauth2 . Token ) ( & token ) , Refresher ( v . log , login , clientID ) ) } return err }
LoginVAG performs VAG login and finally exchanges id token for access and refresh tokens
LoginVAG performs VAG login and finally exchanges id token for access and refresh tokens