auth0-flutter-native
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAuth0 Flutter Native (iOS/Android) Integration
Auth0 Flutter 原生(iOS/Android)集成
auth0_flutterCredentialsManagerAgent instruction: Before providing SDK setup instructions, fetch the latest release version by running one of:bashgh api repos/auth0/auth0-flutter/releases/latest --jq '.tag_name'bashflutter pub info auth0_flutter 2>/dev/null | head -5Or check pub.dev:bashcurl -s https://pub.dev/api/packages/auth0_flutter | python3 -c "import sys,json;print(json.load(sys.stdin)['latest']['version'])"Use the returned version in all dependency lines instead of any hardcoded version below. Current known version:.2.1.0
auth0_flutterCredentialsManagerAgent指令: 在提供SDK设置说明之前,通过运行以下命令之一获取最新版本:bashgh api repos/auth0/auth0-flutter/releases/latest --jq '.tag_name'bashflutter pub info auth0_flutter 2>/dev/null | head -5或者查看pub.dev:bashcurl -s https://pub.dev/api/packages/auth0_flutter | python3 -c "import sys,json;print(json.load(sys.stdin)['latest']['version'])"在所有依赖项行中使用返回的版本,而不是下面任何硬编码的版本。当前已知版本:。2.1.0
When NOT to Use
不适用场景
- Flutter web: Use auth0-flutter-web — web uses a different platform interface () wrapping Auth0 SPA JS
Auth0Web - Native iOS (Swift, no Flutter): Use auth0-swift
- Native Android (Kotlin/Java, no Flutter): Use auth0-android
- React Native: Use auth0-react-native
- React SPA: Use auth0-react
- Node.js/Express servers: Use auth0-express
- Flutter Web:使用auth0-flutter-web——Web端使用不同的平台接口()封装Auth0 SPA JS
Auth0Web - 原生iOS(Swift,无Flutter):使用auth0-swift
- 原生Android(Kotlin/Java,无Flutter):使用auth0-android
- React Native:使用auth0-react-native
- React单页应用:使用auth0-react
- Node.js/Express服务器:使用auth0-express
Prerequisites
前置条件
- Flutter 3.24.0+
- Dart 3.5.0+
- Android: minSdkVersion 21+, compileSdkVersion 34+
- iOS: 14.0+ (Universal Link callbacks require iOS 17.4+)
- Auth0 account — Sign up free
- Auth0 CLI — install instructions (used to create and configure the Auth0 application)
Quick Start Workflow
快速开始流程
Agent instruction: Follow these steps in order. If you encounter an error at any step, attempt to fix it up to 5 times before callingto ask the user for guidance. Always search existing code first — if there are existing login/logout handlers, hook into them rather than creating new ones.AskUserQuestion
Agent指令: 按顺序执行以下步骤。如果在任何步骤中遇到错误,尝试修复最多5次后,再调用向用户寻求指导。始终先搜索现有代码——如果已有登录/登出处理程序,应接入现有程序而非创建新程序。AskUserQuestion
Step 1 — Install SDK
步骤1——安装SDK
Agent instruction: Check the project directory for. If present, add the dependency. If not found, this is not a Flutter project — ask the user.pubspec.yamlRun in the project root:bashflutter pub add auth0_flutterVerify the dependency was added to:pubspec.yamlyamldependencies: auth0_flutter: ^2.1.0
Agent指令: 检查项目目录中是否存在。如果存在,添加依赖项。如果未找到,则这不是Flutter项目——请询问用户。pubspec.yaml在项目根目录运行:bashflutter pub add auth0_flutter验证依赖项已添加到:pubspec.yamlyamldependencies: auth0_flutter: ^2.1.0
Step 2 — Configure Auth0
步骤2——配置Auth0
Note: The Auth0 Domain and Client ID are public configuration (not secrets) — a native app uses PKCE with no client secret. Pass them directly to; there is no need to store them in environment variables or hide them.Auth0(domain, clientId)Agent instruction:
- If Auth0 credentials (domain AND client ID) are already in the user's prompt: Use those values directly in the
constructor and proceed to Step 3.Auth0(...)- If no credentials are provided: Ask the user which setup they prefer using
: "How would you like to set up the Auth0 application — automatic (I run the Auth0 CLI to create it) or manual (you create it in the Auth0 Dashboard and give me the Domain + Client ID)?"AskUserQuestion
- Automatic: Follow the Auth0 CLI steps in the Setup Guide to create the Native application.
- Manual: Ask the user for their Auth0 Domain and Client ID and use them directly.
Follow Setup Guide — Auth0 Configuration for the pre-flight checks and thecommand.auth0 apps create
注意: Auth0域名和客户端ID是公开配置项(不是机密)——原生应用使用PKCE,无需客户端密钥。直接将它们传递给;无需将它们存储在环境变量中或隐藏。Auth0(domain, clientId)Agent指令:
- 如果用户的提示中已提供Auth0凭证(域名和客户端ID): 直接在
构造函数中使用这些值,然后进入步骤3。Auth0(...)- 如果未提供凭证: 使用
询问用户偏好的设置方式:“您希望如何设置Auth0应用——自动方式(我运行Auth0 CLI创建)还是手动方式(您在Auth0控制台创建并提供域名+客户端ID)?”AskUserQuestion
- 自动方式: 按照设置指南中的Auth0 CLI步骤创建原生应用。
- 手动方式: 询问用户的Auth0域名和客户端ID并直接使用。
遵循设置指南——Auth0配置进行预检检查和命令操作。auth0 apps create
Step 3 — Configure Android
步骤3——配置Android
Agent instruction: Edit(orandroid/app/build.gradle) and addbuild.gradle.ktsinsidemanifestPlaceholders. These supply the callback URL the SDK'sandroid { defaultConfig { ... } }intent filter registers — without them the app will not build correctly for Auth0.RedirectActivity
For (Groovy):
android/app/build.gradlegroovy
android {
defaultConfig {
manifestPlaceholders = [auth0Domain: "YOUR_AUTH0_DOMAIN", auth0Scheme: "https"]
}
}For (Kotlin DSL):
android/app/build.gradle.ktskotlin
android {
defaultConfig {
manifestPlaceholders["auth0Domain"] = "YOUR_AUTH0_DOMAIN"
manifestPlaceholders["auth0Scheme"] = "https"
}
}Agent instruction: Useto use Android App Links (recommended). If the app targets a custom scheme instead, set it to a lowercase scheme string and pass the same scheme toauth0Scheme: "https"in Dart. See Setup Guide for details.webAuthentication(scheme: ...)
Agent指令: 编辑(或android/app/build.gradle),在build.gradle.kts内添加android { defaultConfig { ... } }。这些值提供SDK的manifestPlaceholders意图过滤器注册的回调URL——没有这些值,应用将无法针对Auth0正确构建。RedirectActivity
对于(Groovy):
android/app/build.gradlegroovy
android {
defaultConfig {
manifestPlaceholders = [auth0Domain: "YOUR_AUTH0_DOMAIN", auth0Scheme: "https"]
}
}对于(Kotlin DSL):
android/app/build.gradle.ktskotlin
android {
defaultConfig {
manifestPlaceholders["auth0Domain"] = "YOUR_AUTH0_DOMAIN"
manifestPlaceholders["auth0Scheme"] = "https"
}
}Agent指令: 使用来使用Android App Links(推荐)。如果应用使用自定义scheme,请将其设置为小写的scheme字符串,并在Dart代码中传递相同的scheme给auth0Scheme: "https"。详情请参见设置指南。webAuthentication(scheme: ...)
Step 4 — Configure iOS
步骤4——配置iOS
Agent instruction: For the default HTTPS (Universal Link) flow on iOS 17.4+, nochange is required, but the Associated Domains capability must be added in Xcode (Info.plist). For older iOS or a custom URL scheme, add awebcredentials:YOUR_AUTH0_DOMAINentry toCFBundleURLTypes:ios/Runner/Info.plist
xml
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>None</string>
<key>CFBundleURLName</key>
<string>auth0</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
</array>Agent指令: 对于iOS 17.4+上默认的HTTPS(Universal Link)流程,无需修改,但必须在Xcode中添加关联域功能(Info.plist)。对于旧版iOS或自定义URL scheme,需向webcredentials:YOUR_AUTH0_DOMAIN添加ios/Runner/Info.plist条目:CFBundleURLTypes
xml
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>None</string>
<key>CFBundleURLName</key>
<string>auth0</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
</array>Step 5 — Configure Callback URLs
步骤5——配置回调URL
Agent instruction: Register the platform-specific callback and logout URLs using the Auth0 CLI. Determine the Android package name (fromandroid/app/build.gradle) and the iOS bundle identifier (from Xcode /applicationId), then run the command below, replacing the placeholders (PRODUCT_BUNDLE_IDENTIFIER,CLIENT_ID,YOUR_DOMAIN,ANDROID_PACKAGE_NAME) with the project's values:IOS_BUNDLE_IDbashauth0 apps update CLIENT_ID \ --callbacks "https://YOUR_DOMAIN/android/ANDROID_PACKAGE_NAME/callback,https://YOUR_DOMAIN/ios/IOS_BUNDLE_ID/callback" \ --logout-urls "https://YOUR_DOMAIN/android/ANDROID_PACKAGE_NAME/callback,https://YOUR_DOMAIN/ios/IOS_BUNDLE_ID/callback" \ --no-input
The callback URL formats are:
- Android:
https://YOUR_DOMAIN/android/YOUR_PACKAGE_NAME/callback - iOS:
https://YOUR_DOMAIN/ios/YOUR_BUNDLE_ID/callback
Agent指令: 使用Auth0 CLI注册平台特定的回调和登出URL。确定Android包名(来自的android/app/build.gradle)和iOS bundle标识符(来自Xcode /applicationId),然后运行以下命令,将占位符(PRODUCT_BUNDLE_IDENTIFIER,CLIENT_ID,YOUR_DOMAIN,ANDROID_PACKAGE_NAME)替换为项目的值:IOS_BUNDLE_IDbashauth0 apps update CLIENT_ID \ --callbacks "https://YOUR_DOMAIN/android/ANDROID_PACKAGE_NAME/callback,https://YOUR_DOMAIN/ios/IOS_BUNDLE_ID/callback" \ --logout-urls "https://YOUR_DOMAIN/android/ANDROID_PACKAGE_NAME/callback,https://YOUR_DOMAIN/ios/IOS_BUNDLE_ID/callback" \ --no-input
回调URL格式:
- Android:
https://YOUR_DOMAIN/android/YOUR_PACKAGE_NAME/callback - iOS:
https://YOUR_DOMAIN/ios/YOUR_BUNDLE_ID/callback
Step 6 — Implement Authentication
步骤6——实现身份验证
Agent instruction: Search the project for the main app entry point (). Determine the state management approach:main.dart
- Look for
,provider,riverpod,bloc, orGetXimportsmobx- If none found, use basic
withStatefulWidgetsetStateThen follow only the matching path below. If ambiguous, ask via: "Which state management approach does your Flutter app use — Provider, Riverpod, Bloc, or basic setState?"AskUserQuestion
Agent指令: 搜索项目的主应用入口点()。确定状态管理方式:main.dart
- 查找
、provider、riverpod、bloc或GetX导入mobx- 如果未找到,使用基础的
配合StatefulWidgetsetState然后仅遵循以下匹配的流程。如果不确定,通过询问:“您的Flutter应用使用哪种状态管理方式——Provider、Riverpod、Bloc还是基础的setState?”AskUserQuestion
Basic StatefulWidget (Default)
基础StatefulWidget(默认)
Agent instruction: Create anclass, then wire it into the app's root widget. Search for theAuthServiceorMaterialAppwidget and update accordingly. On startup, restore the session from theCupertinoAppcache.CredentialsManager
dart
// lib/auth_service.dart
import 'package:auth0_flutter/auth0_flutter.dart';
class AuthService {
late final Auth0 _auth0;
Credentials? _credentials;
AuthService({required String domain, required String clientId}) {
_auth0 = Auth0(domain, clientId);
}
bool get isAuthenticated => _credentials != null;
UserProfile? get user => _credentials?.user;
/// Restore a stored session on app startup, if one exists.
Future<void> init() async {
final hasValid = await _auth0.credentialsManager.hasValidCredentials();
if (hasValid) {
_credentials = await _auth0.credentialsManager.credentials();
}
}
/// Launch Web Auth via the system browser. Tokens are stored automatically.
Future<void> login() async {
_credentials = await _auth0
.webAuthentication()
.login(scopes: {'openid', 'profile', 'email', 'offline_access'});
}
/// Clear the session in the browser and wipe stored credentials.
Future<void> logout() async {
await _auth0.webAuthentication().logout();
await _auth0.credentialsManager.clearCredentials();
_credentials = null;
}
}dart
// lib/main.dart
import 'package:flutter/material.dart';
import 'package:auth0_flutter/auth0_flutter.dart'; // for WebAuthenticationException
import 'auth_service.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _authService = AuthService(
domain: 'YOUR_AUTH0_DOMAIN',
clientId: 'YOUR_AUTH0_CLIENT_ID',
);
bool _isLoading = true;
void initState() {
super.initState();
_initAuth();
}
Future<void> _initAuth() async {
await _authService.init();
setState(() => _isLoading = false);
}
Widget build(BuildContext context) {
return MaterialApp(
home: _isLoading
? const Scaffold(body: Center(child: CircularProgressIndicator()))
: _authService.isAuthenticated
? HomeScreen(authService: _authService, onChanged: _refresh)
: LoginScreen(authService: _authService, onChanged: _refresh),
);
}
void _refresh() => setState(() {});
}
class LoginScreen extends StatelessWidget {
final AuthService authService;
final VoidCallback onChanged;
const LoginScreen({super.key, required this.authService, required this.onChanged});
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () async {
// Capture the messenger before the await to avoid using
// BuildContext across an async gap.
final messenger = ScaffoldMessenger.of(context);
try {
await authService.login();
onChanged();
} on WebAuthenticationException catch (e) {
messenger.showSnackBar(
SnackBar(content: Text('Login failed: ${e.message}')),
);
}
},
child: const Text('Log In'),
),
),
);
}
}
class HomeScreen extends StatelessWidget {
final AuthService authService;
final VoidCallback onChanged;
const HomeScreen({super.key, required this.authService, required this.onChanged});
Widget build(BuildContext context) {
final user = authService.user;
return Scaffold(
appBar: AppBar(
title: const Text('Home'),
actions: [
IconButton(
onPressed: () async {
await authService.logout();
onChanged();
},
icon: const Icon(Icons.logout),
),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (user?.pictureUrl != null)
CircleAvatar(
backgroundImage: NetworkImage(user!.pictureUrl.toString()),
radius: 40,
),
const SizedBox(height: 16),
Text('Welcome, ${user?.name ?? 'User'}!'),
Text(user?.email ?? ''),
],
),
),
);
}
}Agent指令: 创建类,然后将其接入应用的根组件。查找AuthService或MaterialApp组件并相应更新。启动时,从CupertinoApp缓存中恢复会话。CredentialsManager
dart
// lib/auth_service.dart
import 'package:auth0_flutter/auth0_flutter.dart';
class AuthService {
late final Auth0 _auth0;
Credentials? _credentials;
AuthService({required String domain, required String clientId}) {
_auth0 = Auth0(domain, clientId);
}
bool get isAuthenticated => _credentials != null;
UserProfile? get user => _credentials?.user;
/// Restore a stored session on app startup, if one exists.
Future<void> init() async {
final hasValid = await _auth0.credentialsManager.hasValidCredentials();
if (hasValid) {
_credentials = await _auth0.credentialsManager.credentials();
}
}
/// Launch Web Auth via the system browser. Tokens are stored automatically.
Future<void> login() async {
_credentials = await _auth0
.webAuthentication()
.login(scopes: {'openid', 'profile', 'email', 'offline_access'});
}
/// Clear the session in the browser and wipe stored credentials.
Future<void> logout() async {
await _auth0.webAuthentication().logout();
await _auth0.credentialsManager.clearCredentials();
_credentials = null;
}
}dart
// lib/main.dart
import 'package:flutter/material.dart';
import 'package:auth0_flutter/auth0_flutter.dart'; // for WebAuthenticationException
import 'auth_service.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _authService = AuthService(
domain: 'YOUR_AUTH0_DOMAIN',
clientId: 'YOUR_AUTH0_CLIENT_ID',
);
bool _isLoading = true;
void initState() {
super.initState();
_initAuth();
}
Future<void> _initAuth() async {
await _authService.init();
setState(() => _isLoading = false);
}
Widget build(BuildContext context) {
return MaterialApp(
home: _isLoading
? const Scaffold(body: Center(child: CircularProgressIndicator()))
: _authService.isAuthenticated
? HomeScreen(authService: _authService, onChanged: _refresh)
: LoginScreen(authService: _authService, onChanged: _refresh),
);
}
void _refresh() => setState(() {});
}
class LoginScreen extends StatelessWidget {
final AuthService authService;
final VoidCallback onChanged;
const LoginScreen({super.key, required this.authService, required this.onChanged});
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () async {
// Capture the messenger before the await to avoid using
// BuildContext across an async gap.
final messenger = ScaffoldMessenger.of(context);
try {
await authService.login();
onChanged();
} on WebAuthenticationException catch (e) {
messenger.showSnackBar(
SnackBar(content: Text('Login failed: ${e.message}')),
);
}
},
child: const Text('Log In'),
),
),
);
}
}
class HomeScreen extends StatelessWidget {
final AuthService authService;
final VoidCallback onChanged;
const HomeScreen({super.key, required this.authService, required this.onChanged});
Widget build(BuildContext context) {
final user = authService.user;
return Scaffold(
appBar: AppBar(
title: const Text('Home'),
actions: [
IconButton(
onPressed: () async {
await authService.logout();
onChanged();
},
icon: const Icon(Icons.logout),
),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (user?.pictureUrl != null)
CircleAvatar(
backgroundImage: NetworkImage(user!.pictureUrl.toString()),
radius: 40,
),
const SizedBox(height: 16),
Text('Welcome, ${user?.name ?? 'User'}!'),
Text(user?.email ?? ''),
],
),
),
);
}
}Provider (State Management)
Provider(状态管理)
Agent instruction: If the project uses, createprovideras aAuthServiceand inject it viaChangeNotifierat the app root.ChangeNotifierProvider
dart
// lib/auth_service.dart
import 'package:flutter/foundation.dart';
import 'package:auth0_flutter/auth0_flutter.dart';
class AuthService extends ChangeNotifier {
late final Auth0 _auth0;
Credentials? _credentials;
bool _isLoading = true;
AuthService({required String domain, required String clientId}) {
_auth0 = Auth0(domain, clientId);
}
bool get isAuthenticated => _credentials != null;
bool get isLoading => _isLoading;
UserProfile? get user => _credentials?.user;
Future<void> init() async {
if (await _auth0.credentialsManager.hasValidCredentials()) {
_credentials = await _auth0.credentialsManager.credentials();
}
_isLoading = false;
notifyListeners();
}
Future<void> login() async {
_credentials = await _auth0
.webAuthentication()
.login(scopes: {'openid', 'profile', 'email', 'offline_access'});
notifyListeners();
}
Future<void> logout() async {
await _auth0.webAuthentication().logout();
await _auth0.credentialsManager.clearCredentials();
_credentials = null;
notifyListeners();
}
}dart
// lib/main.dart — wrap with ChangeNotifierProvider
import 'package:provider/provider.dart';
void main() {
runApp(
ChangeNotifierProvider(
create: (_) => AuthService(
domain: 'YOUR_AUTH0_DOMAIN',
clientId: 'YOUR_AUTH0_CLIENT_ID',
)..init(),
child: const MyApp(),
),
);
}For complete patterns with Riverpod, Bloc, biometrics, and advanced scenarios, see Integration Patterns.
Agent指令: 如果项目使用,将provider创建为AuthService,并通过ChangeNotifier在应用根节点注入。ChangeNotifierProvider
dart
// lib/auth_service.dart
import 'package:flutter/foundation.dart';
import 'package:auth0_flutter/auth0_flutter.dart';
class AuthService extends ChangeNotifier {
late final Auth0 _auth0;
Credentials? _credentials;
bool _isLoading = true;
AuthService({required String domain, required String clientId}) {
_auth0 = Auth0(domain, clientId);
}
bool get isAuthenticated => _credentials != null;
bool get isLoading => _isLoading;
UserProfile? get user => _credentials?.user;
Future<void> init() async {
if (await _auth0.credentialsManager.hasValidCredentials()) {
_credentials = await _auth0.credentialsManager.credentials();
}
_isLoading = false;
notifyListeners();
}
Future<void> login() async {
_credentials = await _auth0
.webAuthentication()
.login(scopes: {'openid', 'profile', 'email', 'offline_access'});
notifyListeners();
}
Future<void> logout() async {
await _auth0.webAuthentication().logout();
await _auth0.credentialsManager.clearCredentials();
_credentials = null;
notifyListeners();
}
}dart
// lib/main.dart — wrap with ChangeNotifierProvider
import 'package:provider/provider.dart';
void main() {
runApp(
ChangeNotifierProvider(
create: (_) => AuthService(
domain: 'YOUR_AUTH0_DOMAIN',
clientId: 'YOUR_AUTH0_CLIENT_ID',
)..init(),
child: const MyApp(),
),
);
}有关Riverpod、Bloc、生物识别和高级场景的完整模式,请参见集成模式。
Step 7 — Verify Build
步骤7——验证构建
Agent instruction: Run a build to verify the integration compiles without errors:bashflutter build apk --debug # Android flutter build ios --no-codesign # iOS (on macOS)Then run the app on a device or emulator to test:bashflutter runIf the build fails, review error messages and fix up to 5 times before asking the user.Physical device testing: Biometric protection (Face ID / Touch ID / fingerprint) cannot be exercised on a simulator/emulator — the iOS Simulator and Android emulator have limited or no biometric hardware. Test biometrics and the full Universal Login redirect on a real physical device before release.
Agent指令: 运行构建以验证集成编译无错误:bashflutter build apk --debug # Android flutter build ios --no-codesign # iOS (on macOS)然后在设备或模拟器上运行应用进行测试:bashflutter run如果构建失败,查看错误信息并尝试修复最多5次后再询问用户。物理设备测试: 生物识别保护(面容ID / 触控ID / 指纹)无法在模拟器/仿真器上测试——iOS模拟器和Android仿真器的生物识别硬件有限或没有。发布前请在真实物理设备上测试生物识别和完整的Universal Login重定向流程。
Detailed Documentation
详细文档
- Setup Guide — Auth0 application creation via the Auth0 CLI, Android , iOS
manifestPlaceholders/ Associated Domains, callback URL registrationInfo.plist - Integration Patterns — Web Auth login/logout, CredentialsManager, biometric protection, custom schemes, organizations, API access tokens, state management patterns, error handling
- API Reference & Testing — Full API reference, configuration options, claims reference, testing checklist, troubleshooting
- 设置指南——通过Auth0 CLI创建Auth0应用、Android 、iOS
manifestPlaceholders/ 关联域、回调URL注册Info.plist - 集成模式——Web Auth登录/登出、CredentialsManager、生物识别保护、自定义scheme、组织、API访问令牌、状态管理模式、错误处理
- API参考与测试——完整API参考、配置选项、声明参考、测试清单、故障排除
Common Mistakes
常见错误
| Mistake | Fix |
|---|---|
| Auth0 app type not set to Native | Create the application with |
Missing | Add |
Using | Mobile uses the |
Importing | Only import |
| Callback URL mismatch | Register |
| Scheme mismatch between Gradle and Dart | If |
| Custom scheme with uppercase letters on Android | Android custom schemes must be all lowercase |
| Biometrics prompt never appears on Android | |
| Not storing credentials after login | |
| Not restoring session on startup | Call |
Missing | Add |
Catching generic | Catch |
| 错误 | 修复方法 |
|---|---|
| Auth0应用类型未设置为Native | 使用 |
Android缺失 | 在 |
在移动端使用 | 移动端使用 |
在移动端导入 | 仅导入 |
| 回调URL不匹配 | 在允许的回调URL中注册 |
| Gradle与Dart中的scheme不匹配 | 如果 |
| Android自定义scheme包含大写字母 | Android自定义scheme必须全小写 |
| Android上生物识别提示从未出现 | |
| 登录后未存储凭证 | |
| 启动时未恢复会话 | 在 |
缺失 | 添加 |
捕获通用 | 捕获 |
Related Skills
相关技能
- auth0-quickstart — Initial Auth0 setup and account creation
- auth0-flutter-web — Same SDK, web platform
- auth0-swift — Native iOS (Swift)
- auth0-android — Native Android (Kotlin/Java)
- auth0-quickstart——初始Auth0设置和账户创建
- auth0-flutter-web——同一SDK的Web平台版本
- auth0-swift——原生iOS(Swift)
- auth0-android——原生Android(Kotlin/Java)
Quick Reference
快速参考
| API | Purpose |
|---|---|
| Create the SDK client |
| Launch Universal Login in the system browser |
| Clear the browser session |
| Use a custom URL scheme |
| Get stored credentials (auto-renews if expired) |
| Check for a valid stored session |
| Wipe stored credentials |
| Enable biometric protection of stored credentials |
| API | 用途 |
|---|---|
| 创建SDK客户端 |
| 在系统浏览器中启动Universal Login |
| 清除浏览器会话 |
| 使用自定义URL scheme |
| 获取存储的凭证(过期时自动刷新) |
| 检查是否存在有效的存储会话 |
| 删除存储的凭证 |
| 启用存储凭证的生物识别保护 |