English | 简体中文
You can turn on the server configuration in Development -> Basic Configuration page in the backend of WeChat Public Platform. When users scan the QR code of the public number and follow the public number, Authing will be able to receive the user sweep and follow events to complete the login.
Since only one WeChat server configuration can be set up, you need to choose two different modes according to your specific scenario.
-
Mode 1: Set server address as Authing server endpoint, this mode is the simplest, but all events of WeChat Public will be pushed to Authing server, you will lose other events except sweep and follow.
-
Mode 2: Set the server address as your own server, and then forward the sweep and follow events to Authing server endpoint.
If you have a usage scenario other than user sweep login, you can directly choose mode one; if you have some other business besides user sweep event, such as event push, custom message reply, etc., you need to choose mode two.
This sample project is prepared for a Mode II scenario.
Add the configuration file config.yaml
to the directory where the project is located, the sample configuration file is as follows.
port: 3000
wechat:
appId: xxx
token: xxx
encodingAESKey: xxx
subscribeMessage: Hello and welcome to Authing. \n\nAuthing provides an easy-to-use and scalable identity cloud platform for developers and currently serves tens of thousands of developers and enterprises in seven countries around the world. Our mission is to make identity management easier.
authing:
host: https://core.authing.cn
userPoolId: xxx
socialConnectionIdentifier: xxx
Definition of each item in the configuration file.
port
: The port number on which this service is runningwechat
: WeChat public number related configurationappId
: WeChat Public AppIdtoken
: Token configured in WeChat Public PlatformencodingAESKey
: EncodingAESKey configured in WeChat Public PlatformsubscribeMessage
: Messages sent to users after they follow
authing
: Authing Related Configurationhost
: Authing server address, the default is https://core.authing.cn, if you are deploying privately, you need to change this address to the address of your privatized deployment service.userPoolId
: Authing User Pool IDsocialConnectionIdentifier
: The unique identifier of the WeChat identity source created in Authing, see the documentation for details: https://docs.authing.cn/v2/connections/wechatmp-qrcode/
$ yarn
$ yarn start
- URL to the address where the service is deployed, with the default route being
/wechat/events
. - Please select secure mode for message encryption method.
Once the above steps are completed, the WeChat Public event forwarding service is finished. Next, you can try to do the WeChat public number sweep login, and it will work if there is no problem!
For questions and support please use the official forum. The issue list of this repo is exclusively for bug reports and feature requests.
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push -u origin my-new-feature)
- Create new Pull Request
https://github.com/Authing/.github/blob/main/CONTRIBUTING.md#English
Copyright (c) 2019-present, Authing