providers

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const FacebookProfileEndpoint = "https://graph.facebook.com/me?fields="

Variables

View Source
var DefaultFacebookScopes = []string{"email", "public_profile"}
View Source
var DefaultGoogleScope = []string{"email"}
View Source
var FacebookEndpoint = oauth2.Endpoint{
	AuthURL:  "https://www.facebook.com/dialog/oauth",
	TokenURL: "https://graph.facebook.com/oauth/access_token",
}
View Source
var GoogleEndpoint = oauth2.Endpoint{
	AuthURL:  "https://accounts.google.com/o/oauth2/auth",
	TokenURL: "https://accounts.google.com/o/oauth2/token",
}
View Source
var GoogleProfileEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo"

Functions

func NewFacebook

func NewFacebook(clientKey, secret, callbackURL string, scopes ...string) behemoth.Provider

func NewGoogle

func NewGoogle(clientKey, secret, callbackURL string, scopes ...string) behemoth.Provider

Types

type Facebook

type Facebook struct {
	ProviderName string
	Config       *oauth2.Config
}

FacebookProvider implements the Provider interface for Facebook OAuth. It handles Facebook-specific OAuth flows, including user info retrieval.

func (*Facebook) FetchUserInfo

func (f *Facebook) FetchUserInfo(client *http.Client, ctx context.Context, token *oauth2.Token) (models.UserInfo, error)

FetchUserInfo retrieves user information from Facebook using the provided OAuth client and token. It maps the Facebook user data to a UserInfo struct, including fields like ID, email, and name. Returns the UserInfo or an error if the request or parsing fails.

func (*Facebook) GetConfig

func (f *Facebook) GetConfig() *oauth2.Config

func (*Facebook) GetEndpoint

func (f *Facebook) GetEndpoint() oauth2.Endpoint

GetEndpoint returns Facebook's OAuth 2.0 endpoints.

func (*Facebook) GetScopes

func (f *Facebook) GetScopes() []string

func (*Facebook) Name

func (f *Facebook) Name() string

type Google

type Google struct {
	ProviderName string
	Config       *oauth2.Config
}

GoogleProvider implements the Provider interface for Google OAuth. It handles Google-specific OAuth flows, including user info retrieval.

func (*Google) FetchUserInfo

func (g *Google) FetchUserInfo(client *http.Client, ctx context.Context, token *oauth2.Token) (models.UserInfo, error)

func (*Google) GetConfig

func (g *Google) GetConfig() *oauth2.Config

func (*Google) GetEndpoint

func (g *Google) GetEndpoint() oauth2.Endpoint

GetEndpoint returns Google's OAuth 2.0 endpoints.

func (*Google) GetScopes

func (g *Google) GetScopes() []string

func (*Google) Name

func (g *Google) Name() string

Jump to

Keyboard shortcuts

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