plugins/auth0/skills/auth0-net-ios/SKILL.md
Use when adding Auth0 authentication to .NET iOS applications - integrates Auth0.OidcClient.iOS NuGet package for native login, logout, token management, and user profile via ASWebAuthenticationSession with PKCE. Trigger on .NET iOS auth, .NET 8 iOS auth, .NET 9 iOS auth, add login to .NET iOS, Auth0 iOS C#, Xamarin iOS auth, Auth0 OIDC iOS, ASWebAuthenticationSession login .NET, native iOS C# authentication
npx skillsauth add auth0/agent-skills auth0-net-iosInstall 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 iOS applications. This skill integrates the Auth0.OidcClient.iOS NuGet package which uses ASWebAuthenticationSession 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("ios-")) | .tag_name | ltrimstr("ios-")] | .[0]'Use the returned version in all dependency lines instead of any hardcoded version below.
net9.0-ios target framework)| Use Case | Recommended Skill |
|----------|------------------|
| .NET MAUI cross-platform app (iOS + Android + Windows) | auth0-maui |
| .NET Android-only app | auth0-net-android |
| iOS-only Swift app | auth0-swift |
| 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 Bundle Identifier from
Info.plistor.csproj- Look for existing
Auth0ClientorAuth0ClientOptionsusage to avoid duplicate configuration
dotnet add package Auth0.OidcClient.iOSAuth0Client instantiation, register the URL scheme in Info.plist, and wire login/logout to UI actions.OpenUrl in AppDelegate and call ActivityMediator.Instance.Send(url.AbsoluteString).dotnet buildAgent instruction: When writing the Auth0Client configuration:
- The iOS SDK does NOT require passing an Activity context — just
new Auth0Client(options).- 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 is automatically derived from the Bundle Identifier:
{BundleId}://{domain}/ios/{BundleId}/callback.- The Bundle Identifier must be registered as a URL scheme in
Info.plist.- The
AppDelegatemust handleOpenUrland callActivityMediator.Instance.Send(url.AbsoluteString).- Store tokens securely: After successful login, persist
AccessTokenandRefreshTokenusing iOS Keychain (viaSecurityframework or a wrapper likeKeychainAccess). Never store tokens inUserDefaultsor 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 ASWebAuthenticationSession (the secure system browser). When LoginAsync() is called:
/authorize URL with PKCE parameters (code verifier + challenge){BundleId}://{domain}/ios/{BundleId}/callbackAppDelegate.OpenUrlActivityMediator.Instance.Send(url.AbsoluteString) completes the token exchangeLoginResult with access token, ID token, refresh token, and user claimsThis is the standard OAuth 2.0 Authorization Code flow with PKCE, recommended for native mobile applications.
The native callback URL for .NET iOS uses the Bundle Identifier as the scheme. The format is:
YOUR_BUNDLE_IDENTIFIER://YOUR_AUTH0_DOMAIN/ios/YOUR_BUNDLE_IDENTIFIER/callback
Where YOUR_BUNDLE_IDENTIFIER is the Bundle Identifier for your application, such as com.mycompany.myapplication. For example: com.mycompany.myapp://tenant.us.auth0.com/ios/com.mycompany.myapp/callback.
Note: Some Auth0 native SDKs use
https://{domain}/ios/{bundleId}/callbackor{bundleId}.auth0://{domain}/ios/{bundleId}/callbackas the callback URL format. The .NET iOS SDK uses the Bundle Identifier directly as the URL scheme.
Ensure that the Callback URL is in lowercase.
This URL must be:
Info.plist under CFBundleURLSchemesAuth0.OidcClient.iOS package installed (latest stable version)Auth0Client configured with Domain, ClientId, and Scope = "openid profile email offline_access"Info.plist matching the Bundle IdentifierAppDelegate.OpenUrl implemented with ActivityMediator.Instance.Send(url.AbsoluteString)Security framework with SecKeyChain.Add)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 yourbundleid://{domain}/ios/yourbundleid/callback to Allowed Callback URLs AND Allowed Logout URLs |
| Missing URL scheme in Info.plist | Add CFBundleURLSchemes entry matching your Bundle Identifier |
| Not handling OpenUrl in AppDelegate | Override OpenUrl and call ActivityMediator.Instance.Send(url.AbsoluteString) |
| Using https:// prefix in Domain | Domain should be hostname only (e.g., tenant.auth0.com, not https://tenant.auth0.com) |
| Passing Activity context to Auth0Client (Android pattern) | iOS does not need context — just new Auth0Client(options) |
| URL scheme not matching Bundle Identifier | The CFBundleURLSchemes value must exactly match the Bundle Identifier |
| Storing tokens in UserDefaults or only in memory | Use iOS Keychain via the Security framework (SecKeyChain.Add) for token persistence |
Agent instruction: Remind the user to test on a physical device in addition to simulators. Some WebAuth/ASWebAuthenticationSession behaviors may differ on physical devices vs. simulators. Test the full login → callback → token flow on real hardware before shipping.
Physical Device Testing:
OpenUrl fires in AppDelegate with correct URLUserCancel gracefullyusing Auth0.OidcClient;
var client = new Auth0Client(new Auth0ClientOptions
{
Domain = "YOUR_AUTH0_DOMAIN",
ClientId = "YOUR_AUTH0_CLIENT_ID",
Scope = "openid profile email offline_access"
});
var loginResult = await client.LoginAsync();
BrowserResultType browserResult = await client.LogoutAsync();
Agent instruction: Always include
offline_accessin the scope to enable refresh tokens. This allows the app to silently refresh access tokens without forcing the user to re-authenticate.Agent instruction: After login, always persist tokens to the iOS Keychain using the
Securityframework (SecKeyChain.AddwithSecAccessible.WhenUnlockedThisDeviceOnly). Never store tokens inUserDefaultsor leave them only in memory. Clear tokens on logout. See Integration Patterns for the fullSecureTokenStoragehelper class.
These two pieces are required for the callback to work — see Setup Guide for full code:
CFBundleURLSchemes entry matching the Bundle IdentifierOpenUrl and call ActivityMediator.Instance.Send(url.AbsoluteString)For login with extra parameters, error handling, token refresh, user claims access, and complete ViewController examples, see Integration Patterns.
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.