Documentation ¶
Overview ¶
Package yggdrasil implement Yggdrasil protocol.
Minecraft 1.6 introduced a new authentication scheme called Yggdrasil which completely replaces the previous authentication system. Mojang's other game, Scrolls, uses this method of authentication as well. Mojang has said that this authentication system should be used by everyone for custom logins, but credentials should never be collected from users. ----- https://wiki.vg
Example ¶
var user, password string // set your proof // Sign in resp, err := Authenticate(user, password) if err != nil { fmt.Println(err) os.Exit(1) } id, name := resp.SelectedProfile() fmt.Println("user:", name) fmt.Println("uuid:", id) fmt.Println("astk:", resp.AccessToken()) // Refresh access token if err := resp.Refresh(nil); err != nil { fmt.Println(err) os.Exit(1) } id, name = resp.SelectedProfile() fmt.Println("user:", name) fmt.Println("uuid:", id) fmt.Println("astk:", resp.AccessToken()) // Check access token ok, err := resp.Validate() if err != nil { fmt.Println(err) os.Exit(1) } fmt.Println("at status: ", ok) // Invalidate access token err = resp.Invalidate() if err != nil { fmt.Println(err) os.Exit(1) } // Check access token ok, err = resp.Validate() if err != nil { fmt.Println(err) os.Exit(1) } fmt.Println("at status: ", ok) // Sign out err = SignOut(user, password) if err != nil { fmt.Println(err) os.Exit(1) }
Output:
Index ¶
- Variables
- func SignOut(user, password string) error
- type Access
- func (a *Access) AccessToken() string
- func (a *Access) AvailableProfiles() []Profile
- func (a *Access) GetTokens() Tokens
- func (a *Access) Invalidate() error
- func (a *Access) Refresh(profile *Profile) error
- func (a *Access) SelectedProfile() (ID, Name string)
- func (a *Access) SetTokens(tokens Tokens)
- func (a *Access) Validate() (bool, error)
- type Error
- type Profile
- type Tokens
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var AuthURL = "https://authserver.mojang.com"
Functions ¶
Types ¶
type Access ¶
type Access struct {
// contains filtered or unexported fields
}
func Authenticate ¶
Authenticate authenticates a user using their password.
Example ¶
resp, err := Authenticate("", "") if err != nil { panic(err) } fmt.Println(resp.SelectedProfile()) fmt.Println(resp.AccessToken())
Output:
func (*Access) AccessToken ¶
func (*Access) AvailableProfiles ¶
func (*Access) Invalidate ¶
Invalidate invalidates accessTokens using a client/access token pair.
func (*Access) Refresh ¶
Refresh refreshes a valid accessToken.
It can be used to keep a user logged in between gaming sessions and is preferred over storing the user's password in a file