Social Login (OAuth) with Backend SDKs
This guide is meant for developers that are NOT using Descope Flows to design login screens and authentication methods.
If you'd like to use Descope Flows, Quick Start should be your starting point.
Descope supports many social logins such as Google, Facebook, Microsoft, etc. You can find the currently supported list of social logins in the Descope console at Settings>Authentication Methods>Social Login (OAuth). The Descope console has the defaults set for all social logins. You can customize these by configuring the social logins with your company account.
Backend SDK
Install SDK
Import and initialize SDK
Start OAuth
The first step in OAuth is to start the oauth process with the Identity Provider of your choice such as Google,
Facebook, Microsoft etc. For this step you need call oauth start
function from your app client after user
clicks on social login icon.
Finish OAuth (Exchange Token)
After successful authentication with your IdP the user is redirected to the redirect_url that you provide in the
oauth start
function above. Your application should extract the code from the redirect_url and perform
token exchange as shown below.
Session Validation
The final step of completing the authentication with Descope is to validate the user session. Descope provides rich session management capabilities, including configurable session timeouts and logout functions. You can find the details and sample code for backend session validation here.
Checkpoint
Your application is now integrated with Descope. Please test with sign-up or sign-in use case.