Documentation ¶
Overview ¶
微信相关的 oauth2 基础库
Index ¶
Constants ¶
View Source
const (
ErrCodeOK = 0
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Config Config // TokenStorage, Token 两个字段正常情况下只用指定一个, 如果两个同时被指定了, 优先使用 TokenStorage; TokenStorage TokenStorage Token *Token // Client 自动将最新的 Token 更新到此字段, 不管 Token 字段一开始是否被指定!!! HttpClient *http.Client // 如果 HttpClient == nil 则默认用 http.DefaultClient }
type Config ¶
type Config interface { AuthCodeURL(state string, redirectURIExt url.Values) string // 请求用户授权的地址, 获取code; redirectURIExt 用于扩展回调地址的参数 ExchangeTokenURL(code string) string // 通过code换取access_token的地址 RefreshTokenURL(refreshToken string) string // 刷新access_token的地址 UserInfoURL(accessToken, openId, lang string) string // 获取用户信息的地址, lang可以为空值 }
type Token ¶
type Token struct { AccessToken string `json:"access_token"` CreateAt int64 `json:"create_at"` // 创建时间, unixtime, 分布式系统要求时间同步, 建议使用 NTP ExpiresIn int64 `json:"expires_in"` // 超时时间, seconds RefreshToken string `json:"refresh_token"` OpenId string `json:"openid"` UnionId string `json:"unionid,omitempty"` Scopes []string `json:"scopes,omitempty"` // 用户授权的作用域 }
func (*Token) AccessTokenExpired ¶
判断 Token.AccessToken 是否过期, 过期返回 true, 否则返回 false
Click to show internal directories.
Click to hide internal directories.