Documentation ¶
Index ¶
Constants ¶
View Source
const ( GithubAuthType = "github" WeChatAuthType = "wechat" EmptyAuthType = "nil" )
Variables ¶
This section is empty.
Functions ¶
func IsEmptyAuthType ¶
Types ¶
type AuthProvider ¶
type GitHubUserInfo ¶
type GitHubUserInfo struct { Login string `json:"login"` ID int `json:"id"` NodeId string `json:"node_id"` AvatarUrl string `json:"avatar_url"` GravatarId string `json:"gravatar_id"` Url string `json:"url"` HtmlUrl string `json:"html_url"` FollowersUrl string `json:"followers_url"` FollowingUrl string `json:"following_url"` GistsUrl string `json:"gists_url"` StarredUrl string `json:"starred_url"` SubscriptionsUrl string `json:"subscriptions_url"` OrganizationsUrl string `json:"organizations_url"` ReposUrl string `json:"repos_url"` EventsUrl string `json:"events_url"` ReceivedEventsUrl string `json:"received_events_url"` Type string `json:"type"` SiteAdmin bool `json:"site_admin"` Name string `json:"name"` Company string `json:"company"` Blog string `json:"blog"` Location string `json:"location"` Email string `json:"email"` Hireable bool `json:"hireable"` Bio string `json:"bio"` TwitterUsername interface{} `json:"twitter_username"` PublicRepos int `json:"public_repos"` PublicGists int `json:"public_gists"` Followers int `json:"followers"` Following int `json:"following"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` PrivateGists int `json:"private_gists"` TotalPrivateRepos int `json:"total_private_repos"` OwnedPrivateRepos int `json:"owned_private_repos"` DiskUsage int `json:"disk_usage"` Collaborators int `json:"collaborators"` TwoFactorAuthentication bool `json:"two_factor_authentication"` Plan struct { Name string `json:"name"` Space int `json:"space"` Collaborators int `json:"collaborators"` PrivateRepos int `json:"private_repos"` } `json:"plan"` }
type GithubAuth ¶
func NewGithubAuth ¶
func NewGithubAuth(clientId string, clientSecret string) *GithubAuth
func (*GithubAuth) GetUserInfo ¶
func (auth *GithubAuth) GetUserInfo(token *oauth2.Token) (*UserInfo, error)
type GithubToken ¶
type OAuthManager ¶
type OAuthManager struct {
// contains filtered or unexported fields
}
func NewOAuthManager ¶
func NewOAuthManager(conf map[string]config.OAuthConfig) *OAuthManager
func (*OAuthManager) GetAuthProvider ¶
func (m *OAuthManager) GetAuthProvider(authType string) (AuthProvider, error)
type UserInfo ¶
type WeChatAuth ¶
func NewWeChatAuth ¶
func NewWeChatAuth(clientId string, clientSecret string) *WeChatAuth
func (*WeChatAuth) GetToken ¶
func (auth *WeChatAuth) GetToken(code string) (*oauth2.Token, error)
GetToken use code get access_token (*operation of getting code ought to be done in front) get more detail via: https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html
func (*WeChatAuth) GetUserInfo ¶
func (auth *WeChatAuth) GetUserInfo(token *oauth2.Token) (*UserInfo, error)
GetUserInfo use WechatAccessToken gotten before return WechatUserInfo get more detail via: https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Authorized_Interface_Calling_UnionID.html
type WechatAccessToken ¶
type WechatAccessToken struct { AccessToken string `json:"access_token"` //Interface call credentials ExpiresIn int64 `json:"expires_in"` //access_token interface call credential timeout time, unit (seconds) RefreshToken string `json:"refresh_token"` //User refresh access_token Openid string `json:"openid"` //Unique ID of authorized user Scope string `json:"scope"` //The scope of user authorization, separated by commas. (,) Unionid string `json:"unionid"` //This field will appear if and only if the website application has been authorized by the user's UserInfo. }
type WechatUserInfo ¶
type WechatUserInfo struct { Openid string `json:"openid"` // The ID of an ordinary user, which is unique to the current developer account Nickname string `json:"nickname"` // Ordinary user nickname Sex int `json:"sex"` // Ordinary user gender, 1 is male, 2 is female Language string `json:"language"` City string `json:"city"` // City filled in by general user's personal data Province string `json:"province"` // Province filled in by ordinary user's personal information Country string `json:"country"` // Country, such as China is CN Headimgurl string `json:"headimgurl"` // User avatar, the last value represents the size of the square avatar (there are optional values of 0, 46, 64, 96, 132, 0 represents a 640*640 square avatar), this item is empty when the user does not have a avatar Privilege []string `json:"privilege"` // User Privilege information, json array, such as Wechat Woka user (chinaunicom) Unionid string `json:"unionid"` // Unified user identification. For an application under a WeChat open platform account, the unionid of the same user is unique. }
Click to show internal directories.
Click to hide internal directories.