Documentation
¶
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(w http.ResponseWriter, r *http.Request)
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(w http.ResponseWriter, r *http.Request)
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.
type OnSuccessFuc ¶
type OnSuccessFuc func(w http.ResponseWriter, r *http.Request, userID string)
OnSuccessFuc is the func to be used to handle the successful authentication.