Description
In this video, I’ll show you how to build a secure Login & Registration system in .NET MAUI using JWT Authentication 🚀.
We’ll work on both the JWT Web API (server) and the .NET MAUI client, covering everything from user registration to generating and storing JWT tokens securely.
If you haven’t watched the previous video where we created the JWT Web API, check the pinned comment for the link.
🔐 What you will learn in this video
How to add your Web API project into the MAUI solution
How to create a Register action inside the AuthController
Using GitHub Copilot to speed up your coding
Creating the RegisterModel with Email and Password
Validating user input and checking for existing accounts
Creating new users and assigning the default User role
Testing the Web API using Swagger
Verifying roles inside your database (AspNetRoles)
📱 Building the .NET MAUI Client
Creating a Services folder with an IAuthService interface
Creating a Models folder with AuthResponse (contains the JWT token)
Implementing AuthService using HttpClient
Handling LoginAsync and RegisterAsync
Saving JWT tokens using SecureStorage
Adding Microsoft.Extensions.Http to manage HttpClient
Registering HttpClient and services in MauiProgram.cs
Building the RegisterPage and LoginPage
Validating input, showing alerts, and navigating after success
Using dependency injection correctly throughout the app
Creating a ServiceHelper to simplify resolving services
📲 Testing on Windows & Android
Running the login and registration workflow on Windows
Testing on an Android emulator
Updating API URLs for Android (use 10.0.2.2 instead of localhost)
Switching from HTTPS to HTTP when using local development servers
If this video helps you, please Like & Subscribe.
Feel free to leave your questions or suggestions for future videos!
See you in the next tutorial! 🚀