func Authenticate(user, passwd string) (respData Response, err error) {
	j, err := json.Marshal(Payload{
		Agent: Agent{
			Name:    "Minecraft",
			Version: 1,
		},
		UserName:    user,
		Password:    passwd,
		ClientToken: "gomcbotauther",
		RequestUser: true,
	})
	if err != nil {
		err = fmt.Errorf("encoding json fail: %v", err)
		return
	}
	client := http.Client{}
	PostRequest, err := http.NewRequest(http.MethodPost, "https://authserver.mojang.com/authenticate",
		bytes.NewReader(j))
	if err != nil {
		err = fmt.Errorf("make request error: %v", err)
		return
	}
	PostRequest.Header.Set("User-Agent", "gomcbot")
	PostRequest.Header.Set("Connection", "keep-alive")
	resp, err := client.Do(PostRequest)
	if err != nil {
		err = fmt.Errorf("post authenticate fail: %v", err)
		return
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		err = fmt.Errorf("read authenticate resp fail: %v", err)
		return
	}
	err = json.Unmarshal(body, &respData)
	if err != nil {
		err = fmt.Errorf("unmarshal json data fail: %v", err)
		return
	}
	if respData.Error != "" {
		err = fmt.Errorf("authenticate fail: {error: %q, errorMessage: %q, cause: %q}",
			respData.Error, respData.ErrorMessage, respData.Cause)
		return
	}
	return
}
Authenticate authenticates a user using their password.
package authenticate
import (
	"bytes"
	"encoding/json"
	"fmt"
	mb "github.com/Tnze/gomcbot"
	"io/ioutil"
	"net/http"
)
type Agent struct {
	Name    string `json:"name"`
	Version int    `json:"version"`
}
type Payload struct {
	Agent       `json:"agent"`
	UserName    string `json:"username"`
	Password    string `json:"password"`
	ClientToken string `json:"clientToken"`
	RequestUser bool   `json:"requestUser"`
}