You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently, some wecom account requires a verify-code to login to desktop client. It looks like this:
To make these accounts usable, we implemented verify-code event and verify-code entering method in @juzi/wechaty ASAP. You should note that currently we can only ensure the experience of node version wechaty. We don't have enough resources to push to iterate for other versions. To make full use of your token, we recommend you to use node version of wechaty. ( @juzi/wechaty has only node version provided. )
exportenumVerifyCodeStatus{UNKNOWN=0,WAITING=1,// Waiting for inputEXPIRED=2,// Not implemented yet, now you should judge from the error message of verify-code enter method}exportenumVerifyCodeScene{UNKNOWN=0,LOGIN=1,}typeWechatyEventListenerVerifyCode=(id: string,// verify-code id. When logging in, it is the same with the key of the qr codemessage: string,// message, currently fixed to '请输入企业微信手机端展示的验证码,以继续登录'scene: PUPPET.types.VerifyCodeScene,// scene, now the only scene is LOGINstatus: PUPPET.types.VerifyCodeStatus// scene, now the only status implemented is WAITING)=>void|Promise<void>// listen to the eventbot.on('verify-code',async(id: string,message: string,scene: types.VerifyCodeScene,status: types.VerifyCodeStatus)=>{// code here})
Methods
asyncenterVerifyCode(id: string,code: string,): Promise<void>// enter verify-codeasynccancelVerifyCode(id: string,): Promise<void>// cancel verify-code ( will cause the qrcode to refresh )asyncrefreshQrCode(): Promise<void>// force qrcode to refresh
Notice
When the verify-code event is pushed, the scan event will continue to be pushed ( status 4 Confirmed )。bot developer should check the id of verify-code event, and check it with the qrcode of scan event. qrcode is string like https://wx.work.weixin.qq.com/cgi-bin/crtx_auth?key=${qrcodeKey}&wx=1. The qrcodeKey and the id of verify-code event should be the same. If not, it means a new qrcode has been pushed and you should scan again.
Example
Entering verify-code
conststore={}bot.on('scan',(qrcode: string,status: types.ScanStatus)=>{if(status===types.ScanStatus.Waiting){// New qrcodestore.qrcodeKey=getQrcodeKey(qrcode)}}).on('verify-code',async(id: string,message: string,scene: types.VerifyCodeScene,status: types.VerifyCodeStatus)=>{if(status===types.VerifyCodeStatus.WAITING&&scene===types.VerifyCodeScene.LOGIN&&id===store.qrcodeKey){constverifyCode=awaitgetVerifyCode()// get verify-code from some async methods, e.g. console inputtry{awaitbot.enterVerifyCode(id,verifyCode)// if no error was caught, it means the verify-code is correct, and the login event should be expectedreturn}catch(e){console.log(e.message)// if there is error, please handle according to the message. Currently you can input 3 times.// message keyword: 验证码错误输入错误,请重新输入// message keyword: 验证码错误次数超过阈值,请重新扫码// currently no ```EXPIRED``` event will be pushed, you should decided from the error message.}}})
Refresh Qrcode
awaitbot.cancelVerifyCode(store.qrcodeKey)// cancel the verify-code according to the key. You'll need to scan again, instead of just refresh the verify-codeawaitbot.refreshQrCode()// force refresh qrcode
Misc
Please note that the corresponding doc are subjected to change without editing this issue. Please follow the Feishu Doc. Please also expect our TSS (Token Self Service) platform, where you can buy and renew token, and also get latest doc. Coming soon.
Enter verify code to login to wecom token
Recently, some wecom account requires a verify-code to login to desktop client. It looks like this:
To make these accounts usable, we implemented verify-code event and verify-code entering method in @juzi/wechaty ASAP. You should note that currently we can only ensure the experience of node version wechaty. We don't have enough resources to push to iterate for other versions. To make full use of your token, we recommend you to use node version of wechaty. ( @juzi/wechaty has only node version provided. )
Dependencies
@juzi/[email protected]
@juzi/[email protected]
@juzi/[email protected]
Types
Methods
Notice
When the
verify-code
event is pushed, thescan
event will continue to be pushed (status
4Confirmed
)。bot developer should check theid
ofverify-code
event, and check it with theqrcode
ofscan
event.qrcode
is string likehttps://wx.work.weixin.qq.com/cgi-bin/crtx_auth?key=${qrcodeKey}&wx=1
. TheqrcodeKey
and theid
ofverify-code
event should be the same. If not, it means a new qrcode has been pushed and you should scan again.Example
Entering verify-code
Refresh Qrcode
Misc
Please note that the corresponding doc are subjected to change without editing this issue. Please follow the Feishu Doc. Please also expect our TSS (Token Self Service) platform, where you can buy and renew token, and also get latest doc. Coming soon.
Working Example
Please checkout this codespace
Demo Code
Please checkouot this repo workpro-getting-started.
The text was updated successfully, but these errors were encountered: