In my last post, “Introduction to Web Apps with Next.js”, we went through the steps of setting up a new Next.js project, customizing a landing page, and implementing a very simple web application. In this post, we’ll implement an Open Authentication (OAuth) based Single Sign-On (SSO) API within Next.js using NextAuth.js. We’ll be using GitHub as our provider, but the steps here are very similar for other platforms, such as Google or Discord. This will allow us to place portions of our website behind a login screen, restricting access to certain content or APIs for anonymous visitors.
Quick Start: Spring Security 5 OAuth2 Login
Social logins using Oauth2 have become a industry standard. It has revolutionized the way sites share data and has allowed users to quickly access new applications without having to create a new set of credentials. This article gives an example of why OAuth2 was invented and provides a working example of a Spring Security 5 application integrated with Google.