From 97ce265dab7688aa1f4456411ec0f9f9a306d9fa Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Tue, 29 Apr 2025 13:02:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0github=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E8=AF=B7=E6=B1=82=E6=95=B0=E6=8D=AE=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=9B=BD=E5=A4=96=E4=B8=AD=E7=BB=A7=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/toolService.go | 4 ++-- worker/thirdParty.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/service/toolService.go b/service/toolService.go index a26131e..9658565 100644 --- a/service/toolService.go +++ b/service/toolService.go @@ -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 diff --git a/worker/thirdParty.go b/worker/thirdParty.go index 78f2f2e..ce45714 100644 --- a/worker/thirdParty.go +++ b/worker/thirdParty.go @@ -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)