请求企业微信接口 获取不到userTicket?

2025/01/13
提问

1.问题描述:

请求企业微信接口 https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE

返回数据:

{"DeviceId":"bf3062e6d0b16333","UserId":"13527840460","errcode":0,"errmsg":"ok"}

获取不到userTicket参数,由于userTicket为空导致


2.企业微信应用:首页和主菜单配置信息如下:


https://open.weixin.qq.com/connect/oauth2/authorize?

appid=ww1f5e85e0f4b36866

&redirect_uri=http%3A%2F%2Fgcgl.cckkd.com%3A39199%2Fzgmei%2Fstatic%2Fwechat%2Findex.html

%3F

corp_id=ww1f5e85e0f4b36866

%26

agent_id=1000005&response_type=code&scope=snsapi_base&state=#wechat_redirect


3.scope调整成 snsapi_privateinfo,提示:无效的agentId参数,

4.可用范围设置,如图附件


回答·3

您好,这边打开提示appid无效,请检查传入的appid是否正确。

赞同
评论 4
2025/01/13
https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww1f5e85e0f4b36860&redirect_uri=http%3A%2F%2Fgcgl.ccggd.com%3A29109%2Fzhongmei%2Fstatic%2Fwechat%2Findex.html%3Fcorp_id=ww1f5e85e0f4b36860%26agent_id=1000003&response_type=code&scope=snsapi_userinfo&state=#wechat_redirect
赞同
回复
这个OAuth2链接,是能正常打开的。
赞同
回复
现在的问题是:    
请求企业微信接口 https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE    
返回数据:
{"DeviceId":"bf3062e6d0b16333","UserId":"13527840460","errcode":0,"errmsg":"ok"}
获取不到userTicket参数,如何解决呢?
赞同
回复
这里看起来是家校场景,不支持获取敏感信息的。
赞同
回复
你还未登录,请先登录
2025/01/13

在哪里查看appid?

赞同
评论

您好,这里appid是怎么获取到的呢

赞同
评论 11
2025/01/13
我是去我的企业那边查看的
赞同
回复
2025/01/13
如图
赞同
回复
2025/01/13
准确的url信息:
https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww1f5e85e0f4b36860&redirect_uri=http%3A%2F%2Fgcgl.ccggd.com%3A29109%2Fzhongmei%2Fstatic%2Fwechat%2Findex.html%3Fcorp_id=ww1f5e85e0f4b36860%26agent_id=1000003&response_type=code&scope=snsapi_userinfo&state=#wechat_redirect
赞同
回复
修改scope参数值为snsapi_privateinfo重试一下
赞同
回复
2025/01/13
3.scope调整成 snsapi_privateinfo,提示:无效的agentId参数,
赞同
回复
缺少agentid参数,snsapi_privateinfo时必填,加上重试一下
赞同
回复
调整 scope=snsapi_privateinfo,同时agentid=1000003
完整路径如下:
https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww1f5e85e0f4b36860&redirect_uri=http%3A%2F%2Fgcgl.ccggd.com%3A29109%2Fzhongmei%2Fstatic%2Fwechat%2Findex.html%3Fcorp_id=ww1f5e85e0f4b36860%26agent_id=1000003&response_type=code&scope=snsapi_privateinfo&state=#agentid=1000003#wechat_redirect
还是报错:
agentid=1000003 提示报错信息
赞同
回复
参考一下这里文档
https://developer.work.weixin.qq.com/document/path/91022
赞同
回复
用&agentid拼接不是用#agentid
赞同 1
回复
https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww1f5e85e0f4b36860&redirect_uri=http%3A%2F%2Fgcgl.ccggd.com%3A29109%2Fzhongmei%2Fstatic%2Fwechat%2Findex.html%3Fcorp_id=ww1f5e85e0f4b36860%26agent_id=1000003&response_type=code&scope=snsapi_privateinfo&state=&agentid=1000003#wechat_redirect
配置 &agentid=1000003 后目前可以拿到 user_ticket
赞同
回复
2025/01/14
目前user_ticket的值是已经可以获取成功,登录还有一些问题,我再看看
赞同
回复
你还未登录,请先登录