添加facebook登录
This commit is contained in:
parent
4fe4260784
commit
6b80c3938b
|
|
@ -507,7 +507,7 @@ func DoGoogleCallBack(state *proto.ThirdPartyLoginState, code string) {
|
||||||
log.Println("get google user info error:", err)
|
log.Println("get google user info error:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Println("get github user info:", userInfo)
|
log.Println("get google user info:", userInfo)
|
||||||
var thirdPartyLoginStatus proto.ThirdPartyLoginStatus
|
var thirdPartyLoginStatus proto.ThirdPartyLoginStatus
|
||||||
thirdPartyLoginStatus.Type = state.Platform
|
thirdPartyLoginStatus.Type = state.Platform
|
||||||
thirdPartyUserInfo := proto.ThirdPartyUserInfo{UserID: userInfo.ID, Name: userInfo.Name, Avatar: userInfo.Picture, Email: userInfo.Email}
|
thirdPartyUserInfo := proto.ThirdPartyUserInfo{UserID: userInfo.ID, Name: userInfo.Name, Avatar: userInfo.Picture, Email: userInfo.Email}
|
||||||
|
|
@ -523,24 +523,24 @@ func DoFaceBookCallBack(state *proto.ThirdPartyLoginState, code string) {
|
||||||
tokenResp, err := worker.GetFacebookAccessTokenByCode(code, "https://pm.ljsea.top/tool/third_party_callback", worker.FacebookClientID, worker.FacebookClientSecret)
|
tokenResp, err := worker.GetFacebookAccessTokenByCode(code, "https://pm.ljsea.top/tool/third_party_callback", worker.FacebookClientID, worker.FacebookClientSecret)
|
||||||
|
|
||||||
if tokenResp.AccessToken == "" {
|
if tokenResp.AccessToken == "" {
|
||||||
log.Println("get google access token is empty")
|
log.Println("get facebook access token is empty")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Println("get google access token:", tokenResp)
|
log.Println("get facebook access token:", tokenResp)
|
||||||
//获取用户信息
|
//获取用户信息
|
||||||
userInfo, err := worker.GetFaceBookUserInfo(tokenResp.AccessToken)
|
userInfo, err := worker.GetFaceBookUserInfo(tokenResp.AccessToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("get google user info error:", err)
|
log.Println("get facebook user info error:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Println("get github user info:", userInfo)
|
log.Println("get facebook user info:", userInfo)
|
||||||
var thirdPartyLoginStatus proto.ThirdPartyLoginStatus
|
var thirdPartyLoginStatus proto.ThirdPartyLoginStatus
|
||||||
thirdPartyLoginStatus.Type = state.Platform
|
thirdPartyLoginStatus.Type = state.Platform
|
||||||
thirdPartyUserInfo := proto.ThirdPartyUserInfo{UserID: userInfo.ID, Name: userInfo.Name, Avatar: "", Email: ""}
|
thirdPartyUserInfo := proto.ThirdPartyUserInfo{UserID: userInfo.ID, Name: userInfo.Name, Avatar: "", Email: ""}
|
||||||
HandleThirdPartyLoginStatusV2(state, &thirdPartyLoginStatus, &thirdPartyUserInfo)
|
HandleThirdPartyLoginStatusV2(state, &thirdPartyLoginStatus, &thirdPartyUserInfo)
|
||||||
//更新redis中的第三方登录状态
|
//更新redis中的第三方登录状态
|
||||||
thirdPartyLoginStatusStr, _ := json.Marshal(thirdPartyLoginStatus)
|
thirdPartyLoginStatusStr, _ := json.Marshal(thirdPartyLoginStatus)
|
||||||
log.Println("do handle google callback success, third party login status:", string(thirdPartyLoginStatusStr))
|
log.Println("do handle facebook callback success, third party login status:", string(thirdPartyLoginStatusStr))
|
||||||
worker.SetRedisWithExpire(state.UUID, string(thirdPartyLoginStatusStr), time.Minute*10)
|
worker.SetRedisWithExpire(state.UUID, string(thirdPartyLoginStatusStr), time.Minute*10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -308,6 +308,7 @@ func GetFacebookAccessTokenByCode(code string, redirectURI string, clientID stri
|
||||||
// Code: code,
|
// Code: code,
|
||||||
// RedirectURI: redirectURI,
|
// RedirectURI: redirectURI,
|
||||||
//}
|
//}
|
||||||
|
log.Println("GetFacebookAccessTokenByCode url:", url)
|
||||||
var onlineReq proto.OnlineServerReq
|
var onlineReq proto.OnlineServerReq
|
||||||
onlineReq.Type = "get"
|
onlineReq.Type = "get"
|
||||||
onlineReq.Url = url
|
onlineReq.Url = url
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue