discordoauth

package
v0.0.0-...-bc78d29 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

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

type OnErrorFunc func(w http.ResponseWriter, r *http.Request, status int, msg string)

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.

Jump to

Keyboard shortcuts

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