liveBook · Manning

Authentication

As explained in .NET MAUI in Action

Authentication is the process of verifying the identity of a user, application, or service before allowing access.

Authentication verifies a user, application, or service before granting access. In a .NET MAUI app, it secures communication with a cloud API and keeps login logic out of the UI by placing it in an authentication service. section 8.4 section 8.0

A practical login flow separates interface behavior from authentication work:

  • Define an IAuthService interface with an asynchronous LoginAsync method. section 8.1.1
  • Use a mock service during UI development; the supplied implementation returns a successful result without authenticating API calls. section 8.1.1
  • Disable the login button, show progress, await the service, and display an error when login fails. section 8.1.1
  • Show the login page automatically at startup as a modal page, then remove it programmatically after successful login. section 8.1.1

MauiStockTake login flow

The app starts with LoginPage pushed modally over the existing Shell. Its Login button calls IAuthService.LoginAsync rather than performing authentication in the event handler. A successful result pops the modal page and reveals the application; a failure restores the button and shows an alert. section 8.1.1 section 8.4

Figure 8.1 The LoginPage has a login button. This button triggers an event handler in the code-behind file. The event handler doesn’t handle the process of logging in itself; instead, it calls a Login method in an authentication service.

Use the interaction diagram to trace how a login button event delegates authentication to a service instead of handling it in the page. section 8.1.1

How .NET MAUI in Action covers it

How deep it goes
Defines a service abstraction, mocks success, wires UI state, and uses modal navigation; real authentication remains deferred.
Examples
Uses MauiStockTake's LoginPage, IAuthService, MockAuthService, startup modal navigation, and success or failure UI paths.
What it assumes
Assumes a .NET MAUI application and existing .NET skills while teaching the login flow through a mock service.
What you can do after
Build it from scratch by separating login behavior into a service, testing the UI with a mock, and controlling startup navigation.
How it connects
Connects authentication services with dependency injection, application lifecycle, modal navigation, and cloud APIs.

Also explained in

Compare how 34 books explain authentication →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.