Skip to content

Commit d914844

Browse files
committed
feat: 获取访问用户身份
1 parent 73d9013 commit d914844

File tree

6 files changed

+68
-1
lines changed

6 files changed

+68
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ CI 会在 `go1.17` 和 Go 的当前稳定版本、上一个稳定版本上跑测
8282
* [x] OA (**大部分支持**,见下)
8383
* [x] 会话内容存档 (**大部分支持**,见下)
8484
* [x] 企业微信登录接口 (code2Session)
85+
* [x] 获取访问用户身份 (code2UserInfo)
8586

8687
<details>
8788
<summary>通讯录管理 API</summary>

apis.md.go

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/apis.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Name|Request Type|Response Type|Access Token|URL|Doc
88
`execGetJSAPITicket`|`reqJSAPITicket`|`respJSAPITicket`|+|`GET /cgi-bin/get_jsapi_ticket`|[获取企业的jsapi_ticket](https://open.work.weixin.qq.com/api/doc/90000/90136/90506)
99
`execGetJSAPITicketAgentConfig`|`reqJSAPITicketAgentConfig`|`respJSAPITicket`|+|`GET /cgi-bin/ticket/get`|[获取应用的jsapi_ticket](https://open.work.weixin.qq.com/api/doc/90000/90136/90506)
1010
`execJSCode2Session`|`reqJSCode2Session`|`respJSCode2Session`|+|`GET /cgi-bin/miniprogram/jscode2session`|[临时登录凭证校验code2Session](https://open.work.weixin.qq.com/api/doc/90000/90136/91507)
11+
`execAuthCode2UserInfo`|`reqAuthCode2UserInfo`|`respAuthCode2UserInfo`|+|`GET /cgi-bin/auth/getuserinfo`|[获取访问用户身份](https://developer.work.weixin.qq.com/document/path/91023)
1112

1213
# 成员管理
1314

errcodes/mod.go

+16-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models.go

+27
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,33 @@ type JSCodeSession struct {
739739
SessionKey string `json:"session_key"`
740740
}
741741

742+
// reqAuthCode2UserInfo 获取访问用户身份
743+
type reqAuthCode2UserInfo struct {
744+
Code string
745+
}
746+
747+
var _ urlValuer = reqAuthCode2UserInfo{}
748+
749+
func (x reqAuthCode2UserInfo) intoURLValues() url.Values {
750+
return url.Values{
751+
"code": {x.Code},
752+
}
753+
}
754+
755+
// respAuthCode2UserInfo 获取访问用户身份响应
756+
type respAuthCode2UserInfo struct {
757+
respCommon
758+
AuthCodeUserInfo
759+
}
760+
761+
// AuthCodeUserInfo 访问用户身份
762+
type AuthCodeUserInfo struct {
763+
UserID string `json:"userid,omitempty"`
764+
UserTicket string `json:"user_ticket,omitempty"`
765+
OpenID string `json:"openid,omitempty"`
766+
ExternalUserID string `json:"external_userid,omitempty"`
767+
}
768+
742769
type reqMsgAuditListPermitUser struct {
743770
MsgAuditEdition MsgAuditEdition `json:"type"`
744771
}

token.go

+9
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,12 @@ func (c *WorkwxApp) JSCode2Session(jscode string) (*JSCodeSession, error) {
234234
}
235235
return &resp.JSCodeSession, nil
236236
}
237+
238+
// AuthCode2UserInfo 获取访问用户身份
239+
func (c *WorkwxApp) AuthCode2UserInfo(code string) (*AuthCodeUserInfo, error) {
240+
resp, err := c.execAuthCode2UserInfo(reqAuthCode2UserInfo{Code: code})
241+
if err != nil {
242+
return nil, err
243+
}
244+
return &resp.AuthCodeUserInfo, nil
245+
}

0 commit comments

Comments
 (0)