Home  >  Q&A  >  body text

javascript - WeChat third-party login problem

Can PC-side applications share the same WeChat APPID with WAP-side applications? If so, how can we set up different callbacks

女神的闺蜜爱上我女神的闺蜜爱上我2648 days ago895

reply all(1)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-21 10:14:51

    Yes. Just set your server address in the callback, and this server will process the data sent to you by WeChat. There are usually two methods

    1 No callback required:

    The SDK provided by WeChat to the client. When the client calls the SDK, it will change the local WeChat app. Then the user authorizes the login and then returns to the client. The client will get the token and openid returned by the WeChat SDK. Then pass this token to your server, and the server will use this token to request the WeChat interface to verify whether the token is legal. For example, whether the openid returned by the token
    request is consistent with the one passed by the client. If the token is legal, the server can record the relevant information and then issue your own token or cookie to the client, indicating that the client has logged in.

    2 Use callback:

    The client requests your service, and your service requests the authorization address of WeChat oauth2. WeChat will redirect to an h5 webpage for user authorization. Then WeChat will send some data, such as code, to your callback address. Your server then takes these codes and related keys and then requests the WeChat interface to obtain the token and openid. The server records this openid related information. Then you can authorize your client to indicate login.

    reply
    0
  • Cancelreply