Set up AniList OAuth authentication for your app
AniList OAuth requires different redirect URIs for different platforms:
yourapp://authhttp://localhost:8080/authhttps://yourdomain.com/auth/callback⚠️ Problem: Managing multiple OAuth redirect URIs across platforms can be complex and error-prone.
MiyoList uses a unified web-based OAuth flow that works across all platforms:
https://miyo.my/auth/login in browser
https://miyo.my/auth/callback?code=xxx ✅ Benefits: Single redirect URI, consistent UX, works on all platforms, easier maintenance
Create your own AniList API client:
https://yourdomain.com/auth/callback You can either use MiyoList's gateway or deploy your own:
Use our hosted gateway at https://miyo.my
Redirect URI: https://miyo.my/auth/callback
Clone the website repository and deploy to Vercel/Netlify:
git clone https://github.com/Baconana-chan/miyomy.git cd miyomy && npm install npm run build Deploy to Vercel:
vercel --prod Update your app constants with your Client ID and redirect URI:
lib/core/constants/app_constants.dart
class AppConstants {
// Your AniList Client ID
static const String clientId = 'YOUR_CLIENT_ID';
// Your web OAuth gateway URL
static const String webAuthUrl = 'https://miyo.my/auth/login';
static const String redirectUri = 'https://miyo.my/auth/callback';
} There are several ways to extract the OAuth code:
Best for Windows/macOS/Linux apps
import 'dart:io';
import 'package:url_launcher/url_launcher.dart';
Future<String?> signInWithOAuth() async {
// Start local server on port 8080
final server = await HttpServer.bind(InternetAddress.loopbackIPv4, 8080);
// Open web auth in browser
final authUrl = 'https://miyo.my/auth/login';
await launchUrl(Uri.parse(authUrl));
// Wait for redirect with code
await for (final request in server) {
final params = request.uri.queryParameters;
if (params.containsKey('code')) {
final code = params['code'];
request.response.write('Success! You can close this window.');
await request.response.close();
await server.close();
return code;
}
}
return null;
} Best for Android/iOS apps
Configure your app to handle yourapp://auth?code=xxx deep links
Add to android/app/src/main/AndroidManifest.xml:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="yourapp" />
</intent-filter> Universal fallback method
Show a dialog where user manually copies and pastes the code from the callback page
Once you have the authorization code, exchange it for an access token:
Future<String?> exchangeCodeForToken(String code) async {
final response = await http.post(
Uri.parse('https://anilist.co/api/v2/oauth/token'),
headers: {'Content-Type': 'application/json'},
body: jsonEncode({
'grant_type': 'authorization_code',
'client_id': AppConstants.clientId,
'redirect_uri': AppConstants.redirectUri,
'code': code,
}),
);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
return data['access_token'];
}
return null;
} Your app can now authenticate users with AniList. Next steps: