github

package
v0.0.0-...-03884a7 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthGithub

type AuthGithub struct {
	Config *oauth.OauthConfig

	Name string // 第三方名称

	AuthorizeUrl    string // 授权登录URL
	AccessTokenUrl  string // 获得应用访问令牌URL
	RefreshTokenUrl string // 刷新令牌URL
	UserInfoUrl     string // 获取用户信息URL
}

Github授权登录 https://docs.github.com/zh/apps/overview

func NewAuthGithub

func NewAuthGithub(conf *oauth.OauthConfig) *AuthGithub

func (*AuthGithub) GetAccessToken

func (a *AuthGithub) GetAccessToken(code string) (resp *Token, err error)

获取用户授权凭证

func (*AuthGithub) GetAuthLoginUrl

func (a *AuthGithub) GetAuthLoginUrl(state string) string

1. 获取第三方登录地址(获取授权码code)

func (*AuthGithub) GetAuthUserInfo

func (a *AuthGithub) GetAuthUserInfo(code string) (resp *oauth.UserResult, err error)

获取用户信息

func (*AuthGithub) GetName

func (a *AuthGithub) GetName() string

func (*AuthGithub) GetUserInfo

func (a *AuthGithub) GetUserInfo(accessToken string) (resp *Userinfo, err error)

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	Scope       string `json:"scope"`
	TokenType   string `json:"token_type"`
}

type Userinfo

type Userinfo 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          interface{} `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"`
}

Jump to

Keyboard shortcuts

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