facebook

package
v0.5.25 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EndpointAuthURL 构建用户授权地址的请求地址
	EndpointAuthURL = "https://www.facebook.com/v21.0/dialog/oauth"
	// EndpointTokenURL 交换用户授权的 access_token 的请求地址
	EndpointTokenURL = "https://graph.facebook.com/v21.0/oauth/access_token"
	// EndpointUserInfo 获取用户信息的请求地址
	EndpointUserInfo = "https://graph.facebook.com/me"
)
View Source
const (
	ScopeEmail         = "email"          // 用户邮箱
	ScopePublicProfile = "public_profile" // 用户公开信息
)
View Source
const (
	OAuthUrlIdentifierKey = "facebook.oauth2.url.identifier.%s"
)

Variables

This section is empty.

Functions

func GetOAuthURLIdentifierKey added in v0.5.17

func GetOAuthURLIdentifierKey(state string) string

Types

type OAuth

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

func New

func New(opts ...Option) *OAuth

func (*OAuth) BuildAuthPageURL added in v0.5.17

func (oauth *OAuth) BuildAuthPageURL() (string, error)

BuildAuthPageURL 构建授权页面 URL

func (*OAuth) HandleOAuth2ByAPPAuthToken added in v0.5.17

func (oauth *OAuth) HandleOAuth2ByAPPAuthToken(token string) (*plugin.OAuthUser, error)

HandleOAuth2ByAPPAuthToken 处理 APP 授权登录

func (*OAuth) HandleOAuth2ByAuthCode added in v0.5.17

func (oauth *OAuth) HandleOAuth2ByAuthCode(code *plugin.VerifyCode) (*plugin.OAuthUser, error)

HandleOAuth2ByAuthCode 处理授权码登录授权

func (*OAuth) Provide

func (oauth *OAuth) Provide(ctx context.Context) any

type Option

type Option func(o *Options)

func WithClientID

func WithClientID(clientID string) Option

func WithClientSecret

func WithClientSecret(clientSecret string) Option

func WithRedirectURL

func WithRedirectURL(redirectURL string) Option

func WithScope

func WithScope(scopes []string) Option

type Options

type Options struct {
	ClientID     string
	ClientSecret string
	RedirectURL  string
	Scope        []string
	Fields       []string
}

type User

type User struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

Jump to

Keyboard shortcuts

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