收藏
回答

Can I use qr-based login with an Official Account?

Hi, first of all, thanks for letting me be part of your community and sorry for not using Chinesse.

I have an Official Account of type Service Account which is verified (WeChat Verification, with the orange tick in it). I have successfuly linked this Official Account with a Website App so that users are able to log in to my application just scanning a QR code.

Now I wonder whether I can do that without a Website App (Open Platform), i.e. using the Official Account appId. I have tried it, but I get this error:

For the scope parameter I am setting `snsapi_login`, as I did when using the WebsiteApp appId.

Is it possible to use the qr-based login without a Website App (i.e. directly with an Official Account). If so, am I doing anything wrong?

Again, thank you very much for your help!

回答关注问题邀请回答
收藏

2 个回答

  • 老张
    老张
    2020-07-07

    yes, you can.

    step 1: user click login-in

    step 2: scan the QR code of Service Account that is generated by your server .

    https://developers.weixin.qq.com/doc/offiaccount/en/Account_Management/Generating_a_Parametric_QR_Code.html

    step 3: user must follow the Service Account firstly.

    step 4: WeChat will send a follow event to your server with userInfo such as openid and QR parameters together.

    step 5: bind the user openid and QR parameters, user can login now.

    2020-07-07
    有用 1
    回复 6
    • 艾睿德
      艾睿德
      2020-07-10
      Hello again Lao Zhang,


      I tried the steps you suggested I follow. I managed to let the users scan the QR, which takes them to the Service Account where they can follow it, and then I receive the follow event, just as you said :)


      However, it is not exaclty as the Website App login, where the user is presented with a page (not just a QR) and, once they scan the code, a "request screen" is rendered, rather than a "follow screen". I have attached three images, just in case I didn't make myself understood.


      Do you know if it is possible to present the user with the "request screen" instead of the "follow screen" using a Service Account without a Website App?


      Again, thank you very much ^_^
      2020-07-10
      回复
    • 老张
      老张
      2020-07-10回复艾睿德
      you are right.  Website App login and Official Account login are different.
      with Official Account login, you may need read this:
      https://developers.weixin.qq.com/doc/offiaccount/en/Message_Management/Receiving_event_pushes.html
      there are no "request screen". 
      if you do want a "request screen",you should make it by yourself.
      like such steps:
      1, user scan a QR.
      2, your server push user a message with a web link.
      3, user click the link.
      4, the "request screen" made by your webserver is presented, the UI is just like the third pic.
      2020-07-10
      1
      回复
    • 艾睿德
      艾睿德
      2020-07-13
      Ok. I understand the flow you propose. Thanks!


      I think there is another important difference between both methods: the "website app login" does not imply a "follow" (so, for example, we cannot send messages to the user), whereas the "official account login" does.

      If you don't mind, I'll kindly ask you for another question regarding that solution:


      Up until I have been using a the website app login when trying to login in a browser in the desktop. I also used to have this webpage authorization (https://developers.weixin.qq.com/doc/offiaccount/en/OA_Web_Apps/Wechat_webpage_authorization.html) to allow users to login from the WeChat app. 


      Do you know if I can have a "follow based" login in a page being accessed from the WeChat app? I mean, can I technically "force" a user to follow an official account from the WeChat app? So that I have a "follow-based login" both in the desktop and in the app. I didn't find any way neither to show a follow page from the app nor to send the user back to certain page once he/she has followed the official account.


      Thanks for sharing your knowledge!
      2020-07-13
      回复
    • 老张
      老张
      2020-07-13回复艾睿德
      no.
      Webpage authorization is available only when you access a webpage from the Official Account chat window. that means you should have followed the Official Account already.
      Webpage authorization is used to get user openid. as we know,openid is the ID of user of an AppID(Official Account, etc.), so the openid is created after following.
      2020-07-13
      1
      回复
    • 艾睿德
      艾睿德
      2020-07-14
      Hello again Lao :)


      That's weird. I am running a webpage that allows users to login from the WeChat app (using the Webpage Authorization against our Official Account). 


      For example, I might have received a URL from a friend. The page on that URL contains a button to login using wechat. My user is not following the Official Account, however when I try to login on that website, everything works well: I get a popup requesting me permissions on behalf of the Official Account.


      Maybe I am doing something wrong?
      2020-07-14
      回复
    查看更多(1)
  • 艾睿德
    艾睿德
    2020-07-08

    Thank you very much for your help, Lao Zhang! I'll check it and come back to share my results.

    Cheers!

    2020-07-08
    有用
    回复
登录 后发表内容
问题标签