🔐 Supabase Auth Test

⚠️ ÖNEMLİ UYARI

Bu API, Supabase Flutter paketi ile DOĞRUDAN ÇALIŞMAZ!

Supabase paketi (supabase_flutter), Supabase'in kendi sunucularına özel olarak tasarlanmıştır.

Çözüm: HTTP client (http paketi) kullanarak direkt API çağrıları yapın.

📖 Detaylı Dokümantasyon

📝 Sign Up (Kayıt Ol)

🔑 Sign In (Giriş Yap)

👤 Get User (Kullanıcı Bilgisi)

Önce giriş yapın, token otomatik kaydedilecek.

✏️ Update User (Kullanıcı Güncelle)

🔄 Refresh Token

Refresh token ile yeni access token al.

🚪 Logout

📱 Flutter/Dart Kullanım Örneği

❌ Supabase paketi kullanmayın! HTTP client kullanın:

// ❌ YANLIŞ - Supabase paketi ÇALIŞMAZ // import 'package:supabase_flutter/supabase_flutter.dart'; // ✅ DOĞRU - HTTP client kullanın import 'package:http/http.dart' as http; import 'dart:convert'; class AuthService { static const baseUrl = 'https://dev.motoclup.com'; static const apiKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9'; // Sign In Future> signIn(String email, String password) async { final response = await http.post( Uri.parse('$baseUrl/auth/v1/token?grant_type=password'), headers: { 'Content-Type': 'application/json', 'apikey': apiKey, }, body: jsonEncode({ 'email': email, 'password': password, }), ); if (response.statusCode == 200) { return jsonDecode(response.body); } else { throw Exception(jsonDecode(response.body)['message']); } } // Get User Future> getUser(String token) async { final response = await http.get( Uri.parse('$baseUrl/auth/v1/user'), headers: { 'Authorization': 'Bearer $token', 'apikey': apiKey, }, ); if (response.statusCode == 200) { return jsonDecode(response.body); } else { throw Exception('Failed to get user'); } } } // Kullanım final authService = AuthService(); final result = await authService.signIn('[email protected]', 'password'); print('Token: ${result['access_token']}');

📖 Tam kod örneği için: Auth Dokümantasyonu sayfasına bakın.