Documentation
¶
Overview ¶
package discordoauth provides fasthttp handlers to authenticate with via the Discord OAuth2 endpoint.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiscordOAuth ¶
type DiscordOAuth struct {
// contains filtered or unexported fields
}
DiscordOAuth provides http handlers for authenticating a discord User by your Discord OAuth application.
func NewDiscordOAuth ¶
func NewDiscordOAuth(clientID, clientSecret, redirectURI string, onError OnErrorFunc, onSuccess OnSuccessFuc) *DiscordOAuth
NewDiscordOAuth returns a new instance of DiscordOAuth.
func (*DiscordOAuth) HandlerCallback ¶
func (d *DiscordOAuth) HandlerCallback(ctx *routing.Context) error
HandlerCallback will be requested by discordapp.com on successful app authentication. This handler will check the validity of the passed authorization code by getting a bearer token and trying to get self user data by requesting them using the bearer token. If this fails, onError will be called. Else, onSuccess will be called passing the userID of the user authenticated.
func (*DiscordOAuth) HandlerInit ¶
func (d *DiscordOAuth) HandlerInit(ctx *routing.Context) error
HandlerInit returns a redirect response to the OAuth Apps authentication page.
type OnErrorFunc ¶
OnErrorFunc is the function to be used to handle errors during authentication.