discordoauth

package
v0.0.0-...-553821e Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 5 Imported by: 0

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

type OnErrorFunc func(ctx *routing.Context, status int, msg string) error

OnErrorFunc is the function to be used to handle errors during authentication.

type OnSuccessFuc

type OnSuccessFuc func(ctx *routing.Context, userID string) error

OnSuccessFuc is the func to be used to handle the successful authentication.

Directories

Path Synopsis
package discordoauth provides fasthttp handlers to authenticate with via the Discord OAuth2 endpoint.
package discordoauth provides fasthttp handlers to authenticate with via the Discord OAuth2 endpoint.

Jump to

Keyboard shortcuts

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