modulepackage
0.0.0-20230514095040-ae65713199b3
Repository: https://github.com/pollen5/discord-oauth2.git
Documentation: pkg.go.dev
# README
Discord OAuth 2.0
This is a provider for the package golang.org/x/oauth2 implementing authentication endpoints for Discord
Install
$ go get github.com/ravener/discord-oauth2
Usage
package main
import (
"github.com/ravener/discord-oauth2"
"golang.org/x/oauth2"
)
func main() {
conf := &oauth2.Config{
Endpoint: discord.Endpoint,
Scopes: []string{discord.ScopeIdentify},
RedirectURL: "http://localhost:3000/auth/callback",
ClientID: "id",
ClientSecret: "secret",
}
// Use oauth2 package as normal, i.e
// redirect users to conf.AuthCodeURL("state") for initial auth
// then inside the callback:
// - verify the state param as needed.
// - exchange code with conf.Exchange(oauth2.NoContext, code)
// - Store in session if necessary, etc.
// to get like user's info use conf.Client(ctx, token) to get a proper http client
// for such requests.
}
A full authentication flow example server can be found in example directory
You can join #oauth2
in my Discord Server for support and updates.
License
# Packages
Extremely barebones server to demonstrate OAuth 2.0 flow with Discord Uses native net/http to be dependency-less and easy to run.
# Constants
Whitelist only.
Whitelist only.
All scope constants that can be used.
Whitelist only.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
All scope constants that can be used.
Whitelist only.
Whitelist only.
Whitelist only.
Whitelist only.
All scope constants that can be used.
# Variables
Endpoint is Discord's OAuth 2.0 endpoint.