google

package
v0.5.28 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ScopeProfile Google 获取用户信息的权限
	ScopeProfile = "https://www.googleapis.com/auth/userinfo.profile" // 获取用户信息
	// ScopeEmail Google 获取用户邮箱的权限
	ScopeEmail = "https://www.googleapis.com/auth/userinfo.email" // 获取用户邮箱
)
View Source
const (
	// EndpointUserInfo 获取用户信息的请求地址
	EndpointUserInfo = "https://www.googleapis.com/oauth2/v3/userinfo"
)
View Source
const (
	LockKey = "google.oauth.lock"
)
View Source
const (
	OAuthUrlIdentifierKey = "google.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 (auth *OAuth) BuildAuthPageURL() (string, error)

BuildAuthPageURL 构建授权页面 URL

func (*OAuth) HandleOAuth2ByAPPAuthToken added in v0.5.17

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

HandleOAuth2ByAPPAuthToken 处理 APP 授权登录

func (*OAuth) HandleOAuth2ByAuthCode added in v0.5.17

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

HandleOAuth2ByAuthCode 处理授权码登录授权

func (*OAuth) Provide

func (auth *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(scope []string) Option

type Options

type Options struct {
	ClientID     string
	ClientSecret string
	RedirectURL  string
	Scope        []string
	TTL          time.Duration
}

Jump to

Keyboard shortcuts

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