oauth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterGitHub

func RegisterGitHub(r *ProviderRegistry)

Types

type ProviderRegistry

type ProviderRegistry struct {
	// contains filtered or unexported fields
}

ProviderRegistry provides OAuth endpoint and user-info fetch for known providers.

func NewProviderRegistry

func NewProviderRegistry() *ProviderRegistry

NewProviderRegistry returns a registry with built-in providers (e.g. github).

func (*ProviderRegistry) Endpoint

func (r *ProviderRegistry) Endpoint(providerID string) (oauth2.Endpoint, bool)

Endpoint returns the OAuth2 endpoint for the provider, or false if unknown.

func (*ProviderRegistry) Register

func (r *ProviderRegistry) Register(providerID string, endpoint oauth2.Endpoint, fetcher UserInfoFetcher)

Register adds a provider's endpoint and user-info fetcher.

func (*ProviderRegistry) UserInfo

func (r *ProviderRegistry) UserInfo(ctx context.Context, providerID string, token *oauth2.Token) (providerUserID, email string, err error)

UserInfo fetches provider user id and email using the token. Returns ("", "", err) if provider unknown or fetch fails.

type UserInfoFetcher

type UserInfoFetcher interface {
	FetchUser(ctx context.Context, token *oauth2.Token) (providerUserID, email string, err error)
}

UserInfoFetcher fetches provider user id and email from an OAuth token.

Jump to

Keyboard shortcuts

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