
You should see this page when opening The full code is on step1.py Let's run this app and verify everything is working well: You can also use virtualenv or pipenv to isolate the environment.Ĭreate app.py and the route that displays a login button on the home page:Įnter fullscreen mode Exit fullscreen mode User information page: upon successful login, the user will be able to see information such as name, email, avatar.Īll steps of this tutorial can be found on flask-social-login-example repository.Ī demo is also available at, feel free to remix the code on Glitch 😉.Home page: that only has the login button.If you are interested in implementing a SSO login from scratch, please check out Implement SSO Login the raw way.Īt the end of this article, you should have a Flask app that has the following pages: This can be done without using any external library but in order not to worry too much about the OAuth details, we'll use Requests-OAuthlib, a library to integrate OAuth providers. This post presents a step-by-step guide to add a SSO Login button into a Flask application with SimpleLogin and Facebook as Identity provider. In this post, we'll focus on the OIDC/OAuth2 protocol. OIDC is built on top of OAuth2 and used by social identity providers like Facebook, Google, etc. SAML is used mostly in enterprise application. SSO is usually powered by OIDC (OpenId Connect) or SAML protocol. Your app simply trusts the Identity provider of doing its job of verifying user identity. For developers, removing friction for users is always a huge win and in addition, all login-related features are now delegated to the Identity provider (i.e. For users, they don't have to go through the painful registration process: one click is all it needs. SSO (Single sign-on), mostly known to the public by the everywhere Login with Facebook/Google/Twitter buttons, was invented as a solution for this issue. Without a proper password manager, users tend to reuse the same password which is terrible in terms of security. On the user side, they don't want to go through the lengthy registration process neither as they need to create and remember yet another email/password. These features, though necessary, are not easy to get right and usually not the app's main business. In a modern app, users expect to have standard login-related features like email verification, password reset, multi-factor authentication, etc. Or maybe only authenticated users can have access to reserved content. It's often needed to have some sort of login functionality in an app so users can save data or create their own profiles.
