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

		q, err := v.login(uri, user, password)
		if err == nil {
			data := map[string]string{
				"state":             q.Get("state"),
				"id_token":          q.Get("id_token"),
				"redirect_uri":      "weconnect://authenticated",
				"region":            "emea",
				"access_token":      q.Get("access_token"),
				"authorizationCode": q.Get("code"),
			}

			var req *http.Request
			uri = fmt.Sprintf("%s/login/v1", AppsURI)
			req, err = request.New(http.MethodPost, uri, request.MarshalJSON(data), request.JSONEncoding)

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

		return token, err
	}

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

	return err
}
// LoginID performs ID login and finally exchanges state and id token for access and refresh tokens
LoginID performs ID login and finally exchanges state and id token for access and refresh tokens
// LoginID performs ID login and finally exchanges state and id token for access and refresh tokens
func (v *Identity) LoginID(query url.Values, user, password string) error {
	login := func() (id.Token, error) {
		var token id.Token
		uri := fmt.Sprintf("%s/authorize?%s", AppsURI, query.Encode())
		q, err := v.login(uri, user, password)
		if err == nil {
			data := map[string]string{
				"state":             q.Get("state"),
				"id_token":          q.Get("id_token"),
				"redirect_uri":      "weconnect://authenticated",
				"region":            "emea",
				"access_token":      q.Get("access_token"),
				"authorizationCode": q.Get("code"),
			}
			var req *http.Request
			uri = fmt.Sprintf("%s/login/v1", AppsURI)
			req, err = request.New(http.MethodPost, uri, request.MarshalJSON(data), request.JSONEncoding)
			if err == nil {
				err = v.DoJSON(req, &token)
			}
		}
		return token, err
	}
	token, err := login()
	if err == nil {
		v.TokenSource = oauth.RefreshTokenSource((*oauth2.Token)(&token), id.Refresher(v.log, login))
	}
	return err
}
func ( v * Identity ) LoginID ( query url . Values , user , password string ) error { login := func ( ) ( id . Token , error ) { var token id . Token uri := fmt . Sprintf ( " " , AppsURI , query . Encode ( ) ) q , err := v . login ( uri , user , password ) if err == nil { data := map [ string ] string { " " : q . Get ( " " ) , " " : q . Get ( " " ) , " " : " " , " " : " " , " " : q . Get ( " " ) , " " : q . Get ( " " ) , } var req * http . Request uri = fmt . Sprintf ( " " , AppsURI ) req , err = request . New ( http . MethodPost , uri , request . MarshalJSON ( data ) , request . JSONEncoding ) if err == nil { err = v . DoJSON ( req , & token ) } } return token , err } token , err := login ( ) if err == nil { v . TokenSource = oauth . RefreshTokenSource ( ( * oauth2 . Token ) ( & token ) , id . Refresher ( v . log , login ) ) } return err }
LoginID performs ID login and finally exchanges state and id token for access and refresh tokens
LoginID performs ID login and finally exchanges state and id token for access and refresh tokens