40 lines
1007 B
Go
40 lines
1007 B
Go
package oauth
|
|
|
|
import "time"
|
|
|
|
var _ OAuthInfo = (*WechatOAuthInfo)(nil)
|
|
|
|
type WechatOAuthInfo struct {
|
|
Scope string `json:"scope,omitempty"`
|
|
OpenID string `json:"openid,omitempty"`
|
|
UnionID string `json:"unionid,omitempty"`
|
|
AccessToken string `json:"access_token,omitempty"`
|
|
RefreshToken string `json:"refresh_token,omitempty"`
|
|
ExpiresIn int64 `json:"expires_in,omitempty"`
|
|
}
|
|
|
|
// GetAccessToken implements OAuthInfo.
|
|
func (w *WechatOAuthInfo) GetAccessToken() string {
|
|
return w.AccessToken
|
|
}
|
|
|
|
// GetExpiredAt implements OAuthInfo.
|
|
func (w *WechatOAuthInfo) GetExpiredAt() time.Time {
|
|
return time.Now().Add(time.Duration(w.ExpiresIn) * time.Second)
|
|
}
|
|
|
|
// GetOpenID implements OAuthInfo.
|
|
func (w *WechatOAuthInfo) GetOpenID() string {
|
|
return w.OpenID
|
|
}
|
|
|
|
// GetRefreshToken implements OAuthInfo.
|
|
func (w *WechatOAuthInfo) GetRefreshToken() string {
|
|
return w.RefreshToken
|
|
}
|
|
|
|
// GetUnionID implements OAuthInfo.
|
|
func (w *WechatOAuthInfo) GetUnionID() string {
|
|
return w.UnionID
|
|
}
|