How do you implement OAuth/OpenID Connect login in MAUI?
Short answer
Use WebAuthenticator.Default.AuthenticateAsync to launch a secure system browser for the provider's authorize URL and capture the redirect callback, then exchange the code for tokens. Register a custom URL scheme/callback per platform.
Advertisement
AModel answer
Use WebAuthenticator.Default.AuthenticateAsync to launch a secure system browser for the provider's authorize URL and capture the redirect callback, then exchange the code for tokens. Register a custom URL scheme/callback per platform. Libraries like IdentityModel.OidcClient can handle PKCE and token exchange.
var result = await WebAuthenticator.Default.AuthenticateAsync(
new Uri("https://idp/authorize?..."),
new Uri("myapp://callback"));
var token = result.AccessToken;Real-world example
Users sign in with their corporate identity provider through the system browser and return to the app with tokens.
Likely follow-ups
- What is PKCE? | Why use the system browser over an embedded webview?
Related topics