在接入第三方 H5 应用的时候,js-sdk 在初始化调用 config 可以,但是调用 agentConfig 一直失败。
已经明确他们使用的signature 里面的 js_ticket 分别来自企业 jsticket 和 应用 jsticket 。 调用 config 传入的 js_ticket 来自 https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket (https://work.weixin.qq.com/api/doc/90001/90144/90539#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E7%9A%84jsapi_ticket), 调用 agentConfig 传入的 js_ticket 来自 https://qyapi.weixin.qq.com/cgi-bin/ticket/get?type=agent_config (https://work.weixin.qq.com/api/doc/90001/90144/90539#%E8%8E%B7%E5%8F%96%E5%BA%94%E7%94%A8%E7%9A%84jsapi_ticket)
他们使用的 access_token 是同一个,来自 https://qyapi.weixin.qq.com/cgi-bin/service/get_corp_token (https://work.weixin.qq.com/api/doc/90001/90143/90605)
烦请帮忙排查下。
总结下我目前获取 app_jsticket 的方式:
1: 根据推送的 suiteTicket 和 创建 app 时的 app_secret 和 app_token 生成 suite_access_token.
2: 根据 suite_access_token+ corpId + 永久授权码 获取企业的 access_token (https://qyapi.weixin.qq.com/cgi-bin/service/get_corp_token)
3: 根据 企业的 access_token 获得app_ jsticket (https://qyapi.weixin.qq.com/cgi-bin/ticket/get)
我试过直接使用步骤 1 得到suite_access_token 去调用步骤3。 会报错 invalid access_token 40014
app 使用的 secret 和 token 来自:
试过ios 和 mac 最新版,都不行。
UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)wxwork/3.1.8 (MicroMessenger/6.2) WeChat/2.0.4
UA: Mozilla/5.0 (iPhone; CPU iPhone OS 14_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 wxwork/3.1.9 MicroMessenger/7.0.1 Language/zh ColorScheme/Light
相关的调用日志:
[2021-06-15 09:37:36.752 +0000] INFO (signature/39371 on workMac-mini.local): query {"corpId":"wx274afe64c460e0a1","url":"https%3A%2F%2Fwebapp.beta.saybot.net%2Fwechat-homework-demo%2F"}, body ''
// 获取企业 jsticket
[2021-06-15 09:37:36.758 +0000] INFO (获取suiteTicket/39371 on workMac-mini.local): 推送的suiteTicker 为 1DFxgXJba-RYcZiaXQoUGl3OZebhre4Lh7AZopxRsoRS7yWqPTco7lB_KHrM1MHZ
[2021-06-15 09:37:36.978 +0000] WARN (获取第三方应用凭证/39371 on workMac-mini.local): 使用最新值 uGs3h3Gp3A5mNVyTo_GqwtkIC4punCnmJcpqGpnRmG_SYK3d-kni8SHglvx5juL42ouaot2sToDmfq_NCWH2Wygcc8r-1lyPB4X0ju3SAGtlHr9GBSUo-C9V8-qxXMQ5
[2021-06-15 09:37:37.199 +0000] WARN (获取企业授权token/39371 on workMac-mini.local): 获取最新值 rW47kqrh6NvPMK_hJThw1pGBl3Bp-KAn_PYVIg3_mlT7yP9LdGaISh1DXtPhBeF91L5Uha0VgO3AZcBmPZlieDgHkAdwoHft93lGXAlvp1nF7SXZEoqfuuOtoFtvbuo0-fDcgMb7-3VmXcWAkPHPk0PQntOW_olLqzbm4tbRU8c_VFpOcbGLweMUyz1rMFdugDDbHBUsDOCoda1WYFrxkA
[2021-06-15 09:37:37.418 +0000] WARN (获取jsTicket/39371 on workMac-mini.local): 获取最新企业ticket kgt8ON7yVITDhtdwci0qeSyA3freOmvY_JHQUlzvH40LtXaXaULSElP6StXcQMZRKSf7pwbUHRBmBXnSa41ZCw
// 获取app jsticket
[2021-06-15 09:37:37.421 +0000] INFO (获取suiteTicket/39371 on workMac-mini.local): 推送的suiteTicker 为 1DFxgXJba-RYcZiaXQoUGl3OZebhre4Lh7AZopxRsoRS7yWqPTco7lB_KHrM1MHZ
[2021-06-15 09:37:37.577 +0000] WARN (获取第三方应用凭证/39371 on workMac-mini.local): 使用最新值 uGs3h3Gp3A5mNVyTo_GqwtkIC4punCnmJcpqGpnRmG_SYK3d-kni8SHglvx5juL42ouaot2sToDmfq_NCWH2Wygcc8r-1lyPB4X0ju3SAGtlHr9GBSUo-C9V8-qxXMQ5
[2021-06-15 09:37:37.774 +0000] WARN (获取企业授权token/39371 on workMac-mini.local): 获取最新值 rW47kqrh6NvPMK_hJThw1pGBl3Bp-KAn_PYVIg3_mlT7yP9LdGaISh1DXtPhBeF91L5Uha0VgO3AZcBmPZlieDgHkAdwoHft93lGXAlvp1nF7SXZEoqfuuOtoFtvbuo0-fDcgMb7-3VmXcWAkPHPk0PQntOW_olLqzbm4tbRU8c_VFpOcbGLweMUyz1rMFdugDDbHBUsDOCoda1WYFrxkA
[2021-06-15 09:37:37.948 +0000] WARN (获取jsTicket/39371 on workMac-mini.local): 获取最新应用ticket 6nFbwbCFpPE2rYgixPwQqg==
// 计算 signature
[2021-06-15 09:37:37.951 +0000] INFO (获取signature/39371 on workMac-mini.local): 使用 jsticket kgt8ON7yVITDhtdwci0qeSyA3freOmvY_JHQUlzvH40LtXaXaULSElP6StXcQMZRKSf7pwbUHRBmBXnSa41ZCw, nonceStr S15l5KHqMnhHkG4f09kba3IKeY/zWqzPGwTz6n9B17a6aH8HdsLYD9foB9Qzuf2BOiqZZs3zCupEpubyf7bqzUTL3acmgxTdgo/kPL1N7ozD/7bh0M2tKMyJEKU9vRHf, timestamp 1623749856752, url https://webapp.beta.saybot.net/wechat-homework-demo/ 的 string1: jsapi_ticket=kgt8ON7yVITDhtdwci0qeSyA3freOmvY_JHQUlzvH40LtXaXaULSElP6StXcQMZRKSf7pwbUHRBmBXnSa41ZCw&noncestr=S15l5KHqMnhHkG4f09kba3IKeY/zWqzPGwTz6n9B17a6aH8HdsLYD9foB9Qzuf2BOiqZZs3zCupEpubyf7bqzUTL3acmgxTdgo/kPL1N7ozD/7bh0M2tKMyJEKU9vRHf×tamp=1623749856752&url=https://webapp.beta.saybot.net/wechat-homework-demo/ 得到的signature 3f7fcd32d493ce1c5b62a52d3dc9ff8d097c49c3,
[2021-06-15 09:37:37.952 +0000] INFO (获取signature/39371 on workMac-mini.local): 使用 jsticket 6nFbwbCFpPE2rYgixPwQqg==, nonceStr S15l5KHqMnhHkG4f09kba3IKeY/zWqzPGwTz6n9B17a6aH8HdsLYD9foB9Qzuf2BOiqZZs3zCupEpubyf7bqzUTL3acmgxTdgo/kPL1N7ozD/7bh0M2tKMyJEKU9vRHf, timestamp 1623749856752, url https://webapp.beta.saybot.net/wechat-homework-demo/ 的 string1: jsapi_ticket=6nFbwbCFpPE2rYgixPwQqg==&noncestr=S15l5KHqMnhHkG4f09kba3IKeY/zWqzPGwTz6n9B17a6aH8HdsLYD9foB9Qzuf2BOiqZZs3zCupEpubyf7bqzUTL3acmgxTdgo/kPL1N7ozD/7bh0M2tKMyJEKU9vRHf×tamp=1623749856752&url=https://webapp.beta.saybot.net/wechat-homework-demo/ 得到的signature 1d3f946dfeae7f676b9cf47dd96a36f0832bf90c,
你好,看日志调用agentconfig的时间应该是17:37分,"corpid":"wx274afe64c460e0a1","agentid":0,"url":"https:\/\/webapp.beta.saybot.net\/wechat-homework-demo\/","timestamp":"1623749856752","noncestr":"S15l5KHqMnhHkG4f09kba3IKeY\/zWqzPGwTz6n9B17a6aH8HdsLYD9foB9Qzuf2BOiqZZs3zCupEpubyf7bqzUTL3acmgxTdgo\/kPL1N7ozD\/7bh0M2tKMyJEKU9vRHf","signature":"1d3f946dfeae7f676b9cf47dd96a36f0832bf90c","jsapilist":["checkJsApi","openUserProfile","getContext","selectExternalContact" 请求的内容没有填agentid参数,填上agentid参数看下