oauth

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FacebookEndpoint = Endpoint{
		AuthURL:    "https://www.facebook.com/dialog/oauth",
		TokenURL:   "https://graph.facebook.com/v2.3/oauth/access_token",
		ProfileURL: "https://graph.facebook.com/me",
	}
	GoogleEndpoint = Endpoint{
		AuthURL:    "https://accounts.google.com/o/oauth2/auth",
		TokenURL:   "https://accounts.google.com/o/oauth2/token",
		ProfileURL: "https://www.googleapis.com/oauth2/v2/userinfo",
	}
	PatreonEndpoint = Endpoint{
		AuthURL:    "https://www.patreon.com/oauth2/authorize",
		TokenURL:   "https://api.patreon.com/oauth2/token",
		ProfileURL: "https://api.patreon.com/oauth2/api/current_user",
	}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	ID     string
	Secret string
}

type Endpoint

type Endpoint struct {
	AuthURL    string
	TokenURL   string
	ProfileURL string
}

type PatreonUserProfile

type PatreonUserProfile struct {
	Data patreon.ApiUser `json:"data"`
}

func (PatreonUserProfile) Email

func (me PatreonUserProfile) Email() string

func (PatreonUserProfile) IsEmailVerified

func (me PatreonUserProfile) IsEmailVerified() bool

type Provider

type Provider struct {
	Client   *Client
	Endpoint *Endpoint
}

func (*Provider) ExchangeCode

func (me *Provider) ExchangeCode(code string, redirectURI string) (accessToken string, err error)

func (*Provider) FetchUser

func (me *Provider) FetchUser(accessToken string) (*http.Response, error)

TODO: Allow fields to be specified.

func (*Provider) GetAuthURL

func (me *Provider) GetAuthURL(redirectURI, state, scope string) string

type UserProfile

type UserProfile interface {
	IsEmailVerified() bool
	Email() string
}

func SimpleParser

func SimpleParser(r *http.Response) (UserProfile, error)

type Wrapper

type Wrapper struct {
	Scope         string
	Provider      Provider
	ProfileParser func(*http.Response) (UserProfile, error)
}

func (Wrapper) FetchUser

func (me Wrapper) FetchUser(accessToken string) (up UserProfile, err error)

func (Wrapper) GetAuthURL

func (me Wrapper) GetAuthURL(redirectURI, state string) string

Jump to

Keyboard shortcuts

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