rbxauth

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: MIT Imports: 13 Imported by: 0

README

GoDoc

rbxauth

The rbxauth package is a wrapper for the Roblox authentication API (v2).

Documentation

Overview

The rbxauth package is a wrapper for the Roblox authentication API (v2).

https://auth.roblox.com/docs

Index

Constants

View Source
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

func ReadCookies(r io.Reader) (cookies []*http.Cookie, err error)

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.

func WriteCookies added in v0.3.0

func WriteCookies(w io.Writer, cookies []*http.Cookie) (err error)

WriteCookies formats a list of cookies as a number of "Set-Cookie" HTTP headers and writes them to w.

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) Login

func (cfg *Config) Login(username string, password []byte) ([]*http.Cookie, *Step, error)

Login wraps LoginCred, using a username for the credentials.

func (*Config) LoginCred

func (cfg *Config) LoginCred(cred Cred, password []byte) ([]*http.Cookie, *Step, error)

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) LoginID

func (cfg *Config) LoginID(userID int64, password []byte) ([]*http.Cookie, *Step, error)

LoginID wraps LoginCred, deriving credentials from the given user ID.

func (*Config) Logout

func (cfg *Config) Logout(cookies []*http.Cookie) error

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

func (cfg *Config) Prompt(username string) (Cred, []*http.Cookie, error)

Prompt wraps PromptCred, using a username for the credentials.

func (*Config) PromptCred added in v0.3.0

func (cfg *Config) PromptCred(cred Cred) (Cred, []*http.Cookie, error)

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.

func (*Config) PromptID added in v0.3.0

func (cfg *Config) PromptID(userID int64) (Cred, []*http.Cookie, error)

PromptID wraps PromptCred, deriving credentials from the given user ID.

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 Error

type Error struct {
	Code    int    `json: "code"`
	Message string `json: "message"`
}

Error represents an error returned from an API response.

func (Error) Error

func (err Error) Error() string

Error implements the error interface.

type Errors

type Errors []Error

Errors represents a list of errors returned from an API response.

func (Errors) Error

func (errs Errors) Error() string

Error implements the error interface.

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.

func (*Step) Resend

func (s *Step) Resend() error

Resend retransmits a two-step verification message.

func (*Step) Verify

func (s *Step) Verify(code string, remember bool) ([]*http.Cookie, error)

Verify receives a verification code to complete authentication. If successful, returns HTTP cookies representing the authenticated session.

The remember argument specifies whether the current device should be remembered for future authentication.

Jump to

Keyboard shortcuts

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