添加github第三方请求数据通过国外中继请求
This commit is contained in:
parent
e64aa76456
commit
97ce265dab
|
|
@ -207,7 +207,7 @@ func SetDashboardInfoToRedis() {
|
|||
|
||||
func DoGithubCallBack(state *proto.ThirdPartyLoginState, code string) {
|
||||
//获取Access Token
|
||||
resp, err := worker.ExchangeCodeForAccessToken(proto.Config.GITHUB_CLIENT_ID, proto.Config.GITHUB_CLIENT_SECRET, code, "")
|
||||
resp, err := worker.ExchangeCodeForAccessTokenGithub(proto.Config.GITHUB_CLIENT_ID, proto.Config.GITHUB_CLIENT_SECRET, code, "")
|
||||
if err != nil {
|
||||
log.Println("get github access token error:", err)
|
||||
return
|
||||
|
|
@ -218,7 +218,7 @@ func DoGithubCallBack(state *proto.ThirdPartyLoginState, code string) {
|
|||
}
|
||||
log.Println("get github access token:", resp.AccessToken)
|
||||
//获取用户信息
|
||||
userInfo, err := worker.GetGitHubUserInfo(resp.AccessToken)
|
||||
userInfo, err := worker.GetGitHubUserInfoV2(resp.AccessToken)
|
||||
if err != nil {
|
||||
log.Println("get github user info error:", err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
|
@ -135,11 +136,13 @@ func ExchangeCodeForAccessTokenGithub(clientID, clientSecret, code, redirectURI
|
|||
"token": superTokens[0],
|
||||
"super_id": "1",
|
||||
}
|
||||
log.Println("ExchangeCodeForAccessTokenGithub onlineReqBytes:", string(onlineReqBytes))
|
||||
|
||||
err, respBytes := DoPostRequestJSON("https://vis.ljsea.top/tool/online_server_request?super_id=1", onlineReqBytes, headers)
|
||||
if err != nil {
|
||||
return githubOAuthResponse, err
|
||||
}
|
||||
log.Println("ExchangeCodeForAccessTokenGithub respBytes:", string(respBytes))
|
||||
var onlineResp proto.OutlineServerReqResp
|
||||
err = json.Unmarshal(respBytes, &onlineResp)
|
||||
if err != nil {
|
||||
|
|
@ -191,8 +194,9 @@ func GetGitHubUserInfoV2(accessToken string) (proto.GitHubUserInfo, error) {
|
|||
"token": superTokens[0],
|
||||
"super_id": "1",
|
||||
}
|
||||
|
||||
log.Println("GetGitHubUserInfoV2 onlineReqBytes:", string(onlineReqBytes))
|
||||
err, respBytes := DoPostRequestJSON("https://vis.ljsea.top/tool/online_server_request?super_id=1", onlineReqBytes, headers)
|
||||
log.Println("GetGitHubUserInfoV2 respBytes:", string(respBytes))
|
||||
var onlineResp proto.OutlineServerReqResp
|
||||
var resp proto.GitHubUserInfo
|
||||
err = json.Unmarshal(respBytes, &onlineResp)
|
||||
|
|
|
|||
Loading…
Reference in New Issue