Documentation
¶
Overview ¶
Package mojang allows to login to a mojang account in order to start Minecraft
Index ¶
- Variables
- type AuthResponse
- type Client
- func (m *Client) DecorateRequest(req *http.Request)
- func (m *Client) Login(username string, password string) (*AuthResponse, error)
- func (m *Client) MojangEnsureToken(accessToken string, clientToken string) (*AuthResponse, error)
- func (m *Client) MojangRefreshToken(accessToken string, clientToken string) (*AuthResponse, error)
- type Profile
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorNotFound gets returned when a 404 occurred ErrorNotFound = errors.New("resource not found") // ErrorBadRequest gets returned when a 400 occurred ErrorBadRequest = errors.New("bad Request") )
Functions ¶
This section is empty.
Types ¶
type AuthResponse ¶
type AuthResponse struct { AccessToken string `json:"accessToken"` ClientToken string `json:"clientToken"` SelectedProfile *Profile `json:"selectedProfile"` }
AuthResponse is the response returned by a succefully mojang login
type Client ¶
Client contains credentials and methods to talk to the mojang api
func NewWithClient ¶
NewWithClient returns a new MojangAPI instance using a custom http client supplied as a first parameter
func (*Client) DecorateRequest ¶
DecorateRequest decorates a provided http request with the User-Agent header and a auth header if set
func (*Client) Login ¶
func (m *Client) Login(username string, password string) (*AuthResponse, error)
Login is a convenient method that uses username/password credentials to fetch a token from Mojangs Authentication Server. It then uses (only) that token to login to minepkg
func (*Client) MojangEnsureToken ¶
func (m *Client) MojangEnsureToken(accessToken string, clientToken string) (*AuthResponse, error)
MojangEnsureToken checks if the token need to be refreshed and does so it required. it returns a valid token
func (*Client) MojangRefreshToken ¶
func (m *Client) MojangRefreshToken(accessToken string, clientToken string) (*AuthResponse, error)
MojangRefreshToken refreshed the given token
type Profile ¶
type Profile struct { Agent string `json:"agent"` ID string `json:"id"` Name string `json:"name"` UserID string `json:"userId"` TokenID string `json:"tokenId"` CreatedAt int `json:"createdAt"` LegacyProfile bool `json:"legacyProfile"` Suspended bool `json:"suspended"` Paid bool `json:"paid"` Migrated bool `json:"migrated"` }
Profile is a profile that potentially can be used to launch minecraft