Documentation ¶
Overview ¶
The rbxauth package is a wrapper for the Roblox authentication API (v2).
Index ¶
- Constants
- func ReadCookies(r io.Reader) (cookies []*http.Cookie, err error)
- func WriteCookies(w io.Writer, cookies []*http.Cookie) (err error)
- type Config
- func (cfg *Config) Login(username string, password []byte) ([]*http.Cookie, *Step, error)
- func (cfg *Config) LoginCred(cred Cred, password []byte) ([]*http.Cookie, *Step, error)
- func (cfg *Config) LoginID(userID int64, password []byte) ([]*http.Cookie, *Step, error)
- func (cfg *Config) Logout(cookies []*http.Cookie) error
- func (cfg *Config) Prompt(username string) (Cred, []*http.Cookie, error)
- func (cfg *Config) PromptCred(cred Cred) (Cred, []*http.Cookie, error)
- func (cfg *Config) PromptID(userID int64) (Cred, []*http.Cookie, error)
- type Cred
- type Error
- type Errors
- type StatusError
- type Step
Constants ¶
const DefaultHost = "roblox.com"
DefaultHost defines the default host to use when none is specified.
Variables ¶
This section is empty.
Functions ¶
func ReadCookies ¶ added in v0.3.0
ReadCookies parses cookies from r and returns a list of http.Cookies. Cookies are parsed as a number of "Set-Cookie" HTTP headers. Returns an empty list if the reader is empty.
Types ¶
type Config ¶
type Config struct { // Host is the domain on which to authenticate. Interpreted as DefaultHost // if empty. Host string }
Config configures an authentication action.
func (*Config) LoginCred ¶
LoginCred attempts to authenticate a user by using the provided credentials.
The cred argument specifies the credentials associated with the account to be authenticated. As a special case, if the Type field is "UserID", then the Ident field is interpreted as an integer, indicating the user ID of the account.
The password argument is specified as a slice for future compatibility, where the password may be handled within secured memory.
If multi-step authentication is required, then a Step object is returned. Otherwise, HTTP cookies representing the session are returned.
func (*Config) Logout ¶
Logout destroys the session associated with the given cookies, ensuring that the account has been logged out.
func (*Config) Prompt ¶ added in v0.3.0
Prompt wraps PromptCred, using a username for the credentials.
func (*Config) PromptCred ¶ added in v0.3.0
PromptCred prompts a user to login through standard input. Handles multi-step verification, if necessary.
If cred.Type and/or cred.Ident are empty, then they will be prompted as well.
Returns the updated cred and cookies, or any error that may have occurred.
type Cred ¶ added in v0.3.0
type Cred struct { // Type specifies the kind of identifier. The following types are known to // be accepted by the auth API: // // "Username" : The username associated with the account. // "Email" : The email associated with the account. // "PhoneNumber" : The phone number associated with the account. // Type string // Ident is the identifier itself. Ident string }
Cred holds information used to identify an account.
type StatusError ¶
type StatusError int
StatusError represents an error derived from the status code of an HTTP response.
func (StatusError) Error ¶
func (err StatusError) Error() string
Error implements the error interface.
type Step ¶
type Step struct { // MediaType indicates the means by which the verification code was sent. MediaType string // contains filtered or unexported fields }
Step holds the state of a multi-step verification action.