Documentation ¶
Index ¶
- func DelClient(names ...string)
- func Init(configs ...Config) (err error)
- type Config
- type Endpoint
- type GoOAuth
- func (c *GoOAuth) AuthUrl(opts ...oauth2.AuthCodeOption) string
- func (c *GoOAuth) Exchange(ctx context.Context, authorizationCode string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
- func (c *GoOAuth) GetAccessToken() string
- func (c *GoOAuth) GetRefreshToken() string
- func (c *GoOAuth) GetToken() *oauth2.Token
- func (c *GoOAuth) RefreshToken(ctx context.Context) (*oauth2.Token, error)
- func (c *GoOAuth) TokenSource(ctx context.Context) oauth2.TokenSource
- type IGoOAuth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Name string `yaml:"Name" json:"name,optional"` // Token 信息 AccessToken string `yaml:"AccessToken" json:"accessToken,optional"` RefreshToken string `yaml:"RefreshToken" json:"refreshToken,optional"` ExpiresIn int64 `yaml:"ExpiresIn" json:"expiresIn,optional"` //秒s // 授权参数 OAuthConfig oauth2.Config ClientId string `yaml:"ClientId" json:"clientId,optional"` ClientSecret string `yaml:"ClientSecret" json:"clientSecret,optional"` RedirectURL string `yaml:"RedirectURL" json:"redirectURL,optional"` Endpoint *Endpoint `yaml:"Endpoint" json:"endpoint"` Scopes []string `yaml:"Scopes" json:"scopes,optional"` State string `yaml:"State" json:"state,optional"` }
type Endpoint ¶ added in v1.2.122
type Endpoint struct { TokenURL string `yaml:"TokenURL" json:"tokenURL,optional"` AuthURL string `yaml:"AuthURL" json:"authURL,optional"` DeviceAuthURL string `yaml:"DeviceAuthURL" json:"deviceAuthURL,optional"` AuthStyle oauth2.AuthStyle `yaml:"AuthStyle" json:"authStyle,optional"` } // `yaml:"Endpoint" json:"endpoint"`
type GoOAuth ¶
func (*GoOAuth) AuthUrl ¶
func (c *GoOAuth) AuthUrl(opts ...oauth2.AuthCodeOption) string
获取授权url
自定义参数
param1 := oauth2.SetAuthURLParam("param1", "value1") param2 := oauth2.SetAuthURLParam("param2", "value2")
func (*GoOAuth) Exchange ¶
func (c *GoOAuth) Exchange(ctx context.Context, authorizationCode string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
获取token
自定义参数
param1 := oauth2.SetAuthURLParam("param1", "value1") param2 := oauth2.SetAuthURLParam("param2", "value2")
func (*GoOAuth) GetAccessToken ¶
func (*GoOAuth) GetRefreshToken ¶
func (*GoOAuth) RefreshToken ¶
刷新token
func (*GoOAuth) TokenSource ¶
func (c *GoOAuth) TokenSource(ctx context.Context) oauth2.TokenSource
type IGoOAuth ¶ added in v1.2.122
type IGoOAuth interface { // 自定义参数 // // param1 := oauth2.SetAuthURLParam("param1", "value1") // param2 := oauth2.SetAuthURLParam("param2", "value2") AuthUrl(opts ...oauth2.AuthCodeOption) string Exchange(ctx context.Context, authorizationCode string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error) RefreshToken(ctx context.Context, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error) GetToken() *oauth2.Token }
OAuth2.0 授权接口
Click to show internal directories.
Click to hide internal directories.