oauth2

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Providers = map[string]Provider{
	"google": {
		Endpoint: google.Endpoint,
		Scopes: []string{
			"https://www.googleapis.com/auth/userinfo.email",
			"https://www.googleapis.com/auth/userinfo.profile",
		},
		GetUserInfoFunc: google.GetUserInfoFunc,
		DisplayName:     "Google",
	},
	"github": {
		Endpoint: github.Endpoint,
		Scopes: []string{
			"user:email",
			"read:user",
		},
		GetUserInfoFunc: github.GetUserInfoFunc,
		DisplayName:     "GitHub",
	},
}

Functions

func ProviderNames

func ProviderNames() []string

Types

type Config

type Config = oauth2.Config

type Provider

type Provider struct {
	Endpoint        oauth2.Endpoint
	Scopes          []string
	GetUserInfoFunc func(ctx context.Context, config Config, token *oauth2.Token) (username, email string, err error)
	DisplayName     string
}

type Service

type Service interface {
	Config() Config
	AuthCodeURL(redirectUrl string) string
	Exchange(ctx context.Context, code string, redirectURL string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
	GetUserInfo(ctx context.Context, token *oauth2.Token) (username, email string, err error)
}

func New

func New(
	c *oauth2.Config,
	getUserInfoFunc func(ctx context.Context, config oauth2.Config, token *oauth2.Token) (username string, email string, err error),
) Service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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