Python implementation of QR code QR codes Login

Source: Internet
Author: User
Tags session id

Recently doing a scan code login function, for this i also searched the internet about the implementation of the scan Login. When this function was completed, I decided to organize the whole realization, so that I can see it later and also facilitate other programs with similar Requirements.
To implement a scan login we need to address two issues:
1. How do I resolve a privilege security issue without entering a username and password? In other words, how to let the server know the QR code of the client is a legitimate user?
2. How can the server respond to the Web page in real time based on the User's choice of client?

first of all, we first understand the implementation of the idea, to facilitate our understanding of the way to solve this problem. The two-dimensional code that is logged in is actually aURLinto the form of a QR code, and after scanning the code through the client, nothing but open theurl,I captured the QR code of theURLto behttps://login.weixin.qq.com/l/YdmTu30I5A== , thisURLin theydmtu30i5a==represents the only one for this sessionID,It's kind of like a browser.Session ID, through thisID,Will be able to direct the confirmation results back to the web Page. Using the QR Code login function requires two prerequisites: first, the client needs to installapp. second, users need to log in toapp. https://wx.qq.com/

Python Web Real-time messaging backend server push technology

> Why do we have these two conditions? That is because you need to extract the current app session ID Sent to the server so that the server received the login information and sessionid sessionid The server knows which page to push the feedback results to.

So for the 1th, our key is to make sure that the user is a verified and legitimate user before scanning (authentication can be either a username + password or a secure key ), It's Good to push this result to the server side when choosing whether to log in or Not. If the user does not verify the legality, you can just like the way to tell the user the QR code is not recognized or prompt to login to the appfirst.

  with authentication, now solve the second problem, how to display the feedback results in real time on the web page? A friend may say, the client side is very simple to send a request to the backstage, and the Web page withAjaxperiodically send to server side to see if there is feedback. I am not in favor of this approach becauseAjaxpolling method consumes both client and server resources! Here comes another technology-webreal-time push technology, using push technology can save server-side and client resources, can be stably push and receive any Message. I'm using Third-party push services in the process of implementation .-goeasypush, with it is very easy to implement, other functions in our project are also usedGoeasy Webreal-time push service, so I'm going to use it right here.GoeasyPush to push the login feedback results to the Server. My implementation steps are very simple and will transfer theSession IDas Client-to-web communicationChannel, Web-side subscriptionSession IDas a worthwhileChannel, the client verifies the results andSession IDsent to the server side, the server side can pass thisChanneltake the initiative to push the results to the web version! If the client also needs to make corresponding feedback, then the client only needs to subscribe to thischannel,the server will then push the results to both the Web version and the client, and when the message is received, it can beGoeasycallback function to do what you want to do. About theGoeasythe use of push, we can refer to this blog: http://www.cnblogs.com/jishaochengduo/articles/5552645.html,alsoGoeasyThere is also a push on the official websiteDemo:GoeasyTwo-dimensional codeScan Code LoginDemo,we can see the Effect..

hope to be helpful to everyone, if there is a misunderstanding of the place, but also ask everyone to Treatise.


Python implementation of QR code QR codes Login

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.