MCPcopy Index your code
hub / github.com/TruthHun/BookStack / GetGithubAccessToken

Function GetGithubAccessToken

oauth/github.go:35–54  ·  view source on GitHub ↗

获取accessToken

(code string)

Source from the content-addressed store, hash-verified

33
34//获取accessToken
35func GetGithubAccessToken(code string) (token GithubAccessToken, err error) {
36 var resp string
37 Api := beego.AppConfig.String("oauth::githubAccesstoken")
38 ClientId := beego.AppConfig.String("oauth::githubClientId")
39 ClientSecret := beego.AppConfig.String("oauth::githubClientSecret")
40 Callback := beego.AppConfig.String("oauth::githubCallback")
41 req := httplib.Post(Api)
42 req.Header("Accept", "application/json")
43 if strings.HasPrefix(Api, "https") {
44 req.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
45 }
46 req.Param("code", code)
47 req.Param("client_id", ClientId)
48 req.Param("redirect_uri", Callback)
49 req.Param("client_secret", ClientSecret)
50 if resp, err = req.String(); err == nil {
51 err = json.Unmarshal([]byte(resp), &token)
52 }
53 return
54}
55
56//获取用户信息
57func GetGithubUserInfo(accessToken string) (info GithubUser, err error) {

Callers 1

OauthMethod · 0.92

Calls 1

PostMethod · 0.80

Tested by

no test coverage detected