noauth
This commit is contained in:
parent
91a71ef339
commit
f06581c5d7
|
@ -14,5 +14,5 @@ func NewAppSdk(appid, secret string) *AppSdk {
|
|||
}
|
||||
|
||||
func (o *AppSdk) GetUserInfoByCode(code string) (*UserInfo, error) {
|
||||
return o.getUserInfoByCode(code)
|
||||
return o.getUserInfoByCode(code, true)
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ func (o *BaseSdk) getAccessToken() (string, error) {
|
|||
return o.accessToken, nil
|
||||
}
|
||||
|
||||
func (o *BaseSdk) getUserInfoByCode(code string) (*UserInfo, error) {
|
||||
func (o *BaseSdk) getUserInfoByCode(code string, auth bool) (*UserInfo, error) {
|
||||
url := fmt.Sprintf("%s?appid=%s&secret=%s&code=%s&grant_type=authorization_code",
|
||||
code2AccessTokenUrl, o.appid, o.secret, code)
|
||||
res, err := http.Get(url)
|
||||
|
@ -94,9 +94,12 @@ func (o *BaseSdk) getUserInfoByCode(code string) (*UserInfo, error) {
|
|||
user.AccessToken = g.Get("access_token").String()
|
||||
user.Openid = g.Get("openid").String()
|
||||
|
||||
err = o.getUserInfo(&user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if auth {
|
||||
err = o.getUserInfo(&user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return &user, nil
|
||||
|
|
|
@ -57,8 +57,12 @@ func (o *OaSdk) GetQrCode(sceneStr string) (string, error) {
|
|||
return qrcodeUrl, nil
|
||||
}
|
||||
|
||||
func (o *BaseSdk) GetUserInfoByCode(code string) (*UserInfo, error) {
|
||||
return o.getUserInfoByCode(code)
|
||||
func (o *OaSdk) GetUserInfoByCode(code string) (*UserInfo, error) {
|
||||
return o.getUserInfoByCode(code, true)
|
||||
}
|
||||
|
||||
func (o *OaSdk) GetUserInfoByCodeNoAuth(code string) (*UserInfo, error) {
|
||||
return o.getUserInfoByCode(code, false)
|
||||
}
|
||||
|
||||
func (o *OaSdk) GetUserInfoByOpenid(openid string) (*UserInfo, error) {
|
||||
|
|
Loading…
Reference in New Issue