auth

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package auth provides functions related to game authentication.

Index

Constants

This section is empty.

Variables

View Source
var ClientID string // Client ID for the Azure application
View Source
var ErrNoAccount = errors.New("no account found")
View Source
var RedirectURI *url.URL // Redirect URI for the OAuth2 authorization code grant

Functions

func AuthCodeURL added in v1.3.0

func AuthCodeURL() *url.URL

AuthCodeURL returns an authorization code URL for the user to navigate to

Used for the OAuth2 authorization code grant

func FetchDeviceCode added in v1.3.0

func FetchDeviceCode() (deviceCodeResponse, error)

FetchDeviceCode returns a device code for the user to input to authenticate

Used for the OAuth2 device code grant

func ReadFromCache

func ReadFromCache() error

ReadFromCache reads an AuthStore into the global store from the cache file.

This function should be run in order to load the authentication info from the cache. If it is not, the global AuthStore will be blank.

Types

type AuthStore

type AuthStore struct {
	MSA       msaAuthStore       `json:"msa"`
	XBL       xblAuthStore       `json:"xbl"`
	XSTS      xstsAuthStore      `json:"xsts"`
	Minecraft minecraftAuthStore `json:"minecraft"`
}

An AuthStore is an authentication store which stores necessary information to log in.

var Store AuthStore

Store is the global authentication store.

func (*AuthStore) Clear

func (store *AuthStore) Clear() error

Clear clears the store and writes it to the cache file.

func (*AuthStore) WriteToCache

func (store *AuthStore) WriteToCache() error

WriteToCache writes the store to the cache file.

type Session

type Session struct {
	UUID        string
	Username    string
	AccessToken string
}

A Session holds the necessary information to start Minecraft authenticated.

func Authenticate

func Authenticate() (Session, error)

Authenticate authenticates with all necessary endpoints, or cached data if available and returns a Session.

func AuthenticateWithCode

func AuthenticateWithCode(codeResp deviceCodeResponse) (Session, error)

AuthenticateWithCode authenticates with a device code.

This function blocks until the user has been authenticated, or another error has occurred.

func AuthenticateWithRedirect

func AuthenticateWithRedirect(success, fail string) (Session, error)

AuthenticateWithRedirect authenticates using the OAuth2 Code flow.

success is a string to be shown to the user upon successful authentication. fail is shown if an authentication error occurs.

This function blocks until a response has been received on the local authentication server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL