plugins/auth0/skills/auth0-net-android/SKILL.md
Use when adding Auth0 authentication to .NET Android applications - integrates Auth0.OidcClient.AndroidX NuGet package for native login, logout, token management, and user profile via system browser with PKCE. Trigger on .NET Android auth, .NET 8 Android auth, .NET 9 Android auth, add login to .NET Android, Auth0 Android C#, Xamarin Android auth, Auth0 OIDC Android, Chrome Custom Tabs login .NET, native Android C# authentication
npx skillsauth add auth0/agent-skills auth0-net-androidInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Add Auth0 authentication to .NET Android applications. This skill integrates the Auth0.OidcClient.AndroidX NuGet package which uses Chrome Custom Tabs for secure OIDC-based login and logout flows with PKCE.
Agent instruction: Before providing SDK setup instructions, fetch the latest release version by running:
gh api repos/auth0/auth0-oidc-client-net/releases --jq '[.[] | select(.tag_name | startswith("androidx-")) | .tag_name | ltrimstr("androidx-")] | .[0]'Use the returned version in all dependency lines instead of any hardcoded version below.
| Use Case | Recommended Skill |
|----------|------------------|
| .NET MAUI cross-platform app (iOS + Android + Windows) | auth0-maui |
| .NET iOS-only app | auth0-net-ios |
| Android-only Kotlin app | auth0-android |
| ASP.NET Core server-side web app | auth0-aspnetcore-authentication |
| ASP.NET Core Web API (JWT validation) | auth0-aspnetcore-api |
| React Native mobile app | auth0-react-native |
Agent instruction: Before starting, examine the user's project:
- Identify the .NET version from the
.csprojfile (TargetFramework)- Check for existing authentication implementations — search for existing login/logout handlers and hook into them if found (reuse existing UI elements like login buttons rather than creating duplicates)
- Note the project's namespace and package name from the
.csprojorAndroidManifest.xml- Look for existing
Auth0ClientorAuth0ClientOptionsusage to avoid duplicate configuration
dotnet add package Auth0.OidcClient.AndroidXAuth0Client instantiation, configure the IntentFilter on your Activity, and wire login/logout to UI actions.OnNewIntent and call ActivityMediator.Instance.Send(intent.DataString) to complete the authentication flow.dotnet buildAgent instruction: When writing the Auth0Client configuration:
- Pass
this(the Activity) as the second argument toAuth0Clientconstructor.- Always set
Scope = "openid profile email offline_access"— theoffline_accessscope is required to receive refresh tokens, enabling silent token renewal without re-prompting the user.- The callback URL format is
YOUR_ANDROID_PACKAGE_NAME://YOUR_AUTH0_DOMAIN/android/YOUR_ANDROID_PACKAGE_NAME/callback— all lowercase.- The
DataSchemein theIntentFiltermust be lowercase or Android will not receive callbacks.- Set
LaunchMode = LaunchMode.SingleTaskon the Activity to prevent duplicate instances. Do NOT useSingleTop— it does not correctly handle the callback redirect and will create duplicate Activity instances.- The Activity should either extend
Auth0ClientActivityOR manually overrideOnNewIntentand callActivityMediator.Instance.Send(intent.DataString).- Store tokens securely: After successful login, persist
AccessTokenandRefreshTokenusingSecureStorage(MAUI/Essentials) orEncryptedSharedPreferences(AndroidX Security — requiresdotnet add package Xamarin.AndroidX.Security.SecurityCrypto). Never store tokens in plainSharedPreferencesor in-memory variables only.After writing configuration and code, verify the build succeeds:
dotnet buildIf the build fails, attempt to fix the issue. After 5-6 failed attempts, ask the user for help.
The SDK uses the WebAuth pattern via Chrome Custom Tabs (the system browser). When LoginAsync() is called, the SDK:
/authorize URL with PKCE parametersOnNewIntentActivityMediator completes the token exchangeThis is the standard OAuth 2.0 Authorization Code flow with PKCE, recommended for native mobile applications.
The native callback URL for .NET Android uses the package name as the scheme. The format is:
YOUR_ANDROID_PACKAGE_NAME://YOUR_AUTH0_DOMAIN/android/YOUR_ANDROID_PACKAGE_NAME/callback
Where YOUR_ANDROID_PACKAGE_NAME is the Package Name for your application, such as com.mycompany.myapplication. For example: com.mycompany.myapp://tenant.us.auth0.com/android/com.mycompany.myapp/callback.
Note: Some Auth0 native SDKs use
https://{domain}/android/{package}/callbackas the callback URL format. The .NET Android SDK uses the package name as the URL scheme instead.
Ensure that the Callback URL is in lowercase.
This URL must be:
IntentFilter attributes (DataScheme, DataHost, DataPathPrefix) on your ActivityAuth0.OidcClient.AndroidX package installed (latest stable version)Auth0Client configured with Domain, ClientId, and Scope = "openid profile email offline_access"IntentFilter configured on Activity with correct DataScheme, DataHost, DataPathPrefixLaunchMode = LaunchMode.SingleTask set on ActivityOnNewIntent handled with ActivityMediator.Instance.Send(intent.DataString)Auth0ClientOptions reference, claims, testing checklist, troubleshooting| Mistake | Fix |
|---------|-----|
| App type not set to Native in Auth0 Dashboard | Change application type to "Native" in Dashboard settings |
| Missing callback URL in Auth0 Dashboard | Add yourpackagename://{domain}/android/yourpackagename/callback to Allowed Callback URLs AND Allowed Logout URLs |
| DataScheme not lowercase | Android requires the scheme to be lowercase — use lowercase package name |
| Missing LaunchMode.SingleTask | Set LaunchMode = LaunchMode.SingleTask on the Activity to prevent duplicate instances |
| Not handling OnNewIntent | Override OnNewIntent and call ActivityMediator.Instance.Send(intent.DataString) |
| Using https:// prefix in Domain | Domain should be hostname only (e.g., tenant.auth0.com, not https://tenant.auth0.com) |
| Not passing Activity context to Auth0Client | Pass this as second parameter: new Auth0Client(options, this) |
| IntentFilter DataHost/DataPathPrefix mismatch | Ensure DataHost matches your Auth0 domain and DataPathPrefix is /android/yourpackagename/callback |
| Missing offline_access scope | Always include offline_access in Scope to receive refresh tokens for silent renewal |
| Using LaunchMode.SingleTop instead of SingleTask | Must use LaunchMode.SingleTask — SingleTop does not correctly handle the Auth0 callback redirect |
| Storing tokens in plain SharedPreferences | Use SecureStorage or EncryptedSharedPreferences from AndroidX Security library |
Agent instruction: Remind the user to test on a physical device in addition to emulators. Some WebAuth behaviors (Chrome Custom Tabs, URL scheme interception) may differ on physical devices vs. emulators. Test the full login → callback → token flow on real hardware before shipping.
Physical Device Testing:
OnNewIntent fires with correct intent dataUserCancel gracefullyusing Auth0.OidcClient;
var client = new Auth0Client(new Auth0ClientOptions
{
Domain = "YOUR_AUTH0_DOMAIN",
ClientId = "YOUR_AUTH0_CLIENT_ID",
Scope = "openid profile email offline_access"
}, this);
var loginResult = await client.LoginAsync();
var loginResult = await client.LoginAsync();
if (loginResult.IsError)
{
Debug.WriteLine($"An error occurred during login: {loginResult.Error}");
}
var loginResult = await client.LoginAsync();
if (!loginResult.IsError)
{
Debug.WriteLine($"Authentication successful.");
}
if (!loginResult.IsError)
{
Debug.WriteLine($"name: {loginResult.User.FindFirst(c => c.Type == "name")?.Value}");
Debug.WriteLine($"email: {loginResult.User.FindFirst(c => c.Type == "email")?.Value}");
}
if (!loginResult.IsError)
{
foreach (var claim in loginResult.User.Claims)
{
Debug.WriteLine($"{claim.Type} = {claim.Value}");
}
}
BrowserResultType browserResult = await client.LogoutAsync();
[Activity(Label = "AndroidSample", MainLauncher = true, Icon = "@drawable/icon",
LaunchMode = LaunchMode.SingleTask)]
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataScheme = "YOUR_ANDROID_PACKAGE_NAME",
DataHost = "YOUR_AUTH0_DOMAIN",
DataPathPrefix = "/android/YOUR_ANDROID_PACKAGE_NAME/callback")]
public class MainActivity : Activity
{
// Code omitted
}
protected override async void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
Auth0.OidcClient.ActivityMediator.Instance.Send(intent.DataString);
}
development
Use when adding login, logout, and user profile to a Laravel web application using session-based authentication - integrates auth0/login (laravel-auth0) for guard-based auth with auto-registered routes.
tools
Use when securing Laravel API endpoints with JWT Bearer token validation, scope/permission checks, or stateless auth - integrates auth0/login (laravel-auth0) with the AuthorizationGuard for REST APIs receiving access tokens from SPAs, mobile apps, or other clients. Triggers on: Laravel API auth, auth0.authorizer, AuthorizationGuard, Laravel JWT, stateless Bearer.
development
Use when adding Auth0 authentication to a Flutter web application — integrates the auth0_flutter SDK (web platform) for browser-based authentication using redirect login, popup login, and credential caching.
development
Use when adding Auth0 authentication to a Flutter mobile application (iOS/Android) — integrates the auth0_flutter SDK (native platform) for Web Auth login/logout via the system browser, with secure credential storage and biometric protection through the CredentialsManager.