Password Authentication 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.
The Password-based authentication method lets you authenticate end users using a secret string of characters known only to the user.
Descope recommends using an email address as the user identifier; this allows you to utilize passwordless methods like Magic Link in addition to passwords. These methods could be used for authentication when users forget their password or need to reset it easily.
Use Cases
- New user signup: User Sign-Up returns a jwt for the user.
- Existing user signin: User Sign-In returns a jwt for the user.
Backend SDK
Install SDK
Import and initialize SDK
User Sign-Up
For registering a new user, your application client should accept user information, including an email or phone number used for verification. The application client should then send this information to your application server. Signing up via password returns the user's JWT.
User Sign-In
For authenticating a user, your application client should accept the user's identity (typically an email address or phone number) and password. The application client should send this information to your application server. Signing in via password returns the user's JWT.
Update Password
Update a password for an existing logged in user using their refresh token.
Replace Password
Replace a password with a new one. The old password is used to authenticate the user before replacing the password. If the user cannot be authenticated, this operation will fail.
Reset Password
Sends a password reset prompt to the user with the given login id according to the password settings defined in the Descope console.
Note
The user's email must be verified in order for the password reset method to complete.
Get Password Policy
Get the configured password policy for the project.
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.