This commit is contained in:
邹宗楠
2023-01-30 14:45:04 +08:00
parent a67c57c92e
commit fac70ca58a
4 changed files with 73 additions and 10 deletions

View File

@@ -1,8 +1,29 @@
package kuaishou_mini
import (
"errors"
"git.rosy.net.cn/baseapi/utils"
)
// AuthLoginKuaiShou 快手授权登录
func (a *API) AuthLoginKuaiShou(jsCode string) {
func (a *API) AuthLoginKuaiShou(jsCode string) (sessionKey, openId string, err error) {
if a.appId == "" || a.appSecret == "" || jsCode == "" {
return
return "", "", err
}
result, err := a.AccessAPI2(KuaiShouAuthLogin, map[string]interface{}{"js_code": jsCode, "app_id": a.appId, "app_secret": a.appSecret})
if err != nil {
return "", "", err
}
auth := GetLoginAuth{}
if err := utils.Map2StructByJson(result, &auth, false); err != nil {
return "", "", err
}
if auth.Error != "" {
return "", "", errors.New(auth.ErrorMsg)
}
return auth.SessionKey, auth.OpenId, nil
}