I come to ask you for help.
One month ago, everything worked perfectly for the email/password authentication with a custom Google token generated by my API.
On the web version, everything works correctly, but on the app version, it no longer works even though both are using the same API and the same functions for registering or connecting a user.
The authToken generated by the API with the help of Firebase Auth is the same for both the app and the web.
The .json keys are configured correctly on my servers and in my Flutter application. The reverse DNS entries are also correctly set up.
Here are the details of my environment:
[✓] Flutter (Channel stable, 3.7.12, on macOS 14.1 23B2073 darwin-arm64, locale fr-FR)
• Flutter version 3.7.12 on channel stable at /Users/mehdimettag/Documents/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4d9e56e694 (1 year, 1 month ago), 2023-04-17 21:47:46 -0400
• Engine revision 1a65d409c7
• Dart version 2.19.6
• DevTools version 2.20.1
[✓] Android toolchain – develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/mehdimettag/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode – develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.15.2
[✓] Chrome – develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
???? https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
???? https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] VS Code (version 1.88.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.86.0
firebase_auth: ^4.8.0
cloud_firestore: ^4.10.0
firebase_storage: ^11.2.3
firebase_dynamic_links: ^5.0.1
firebase_core_platform_interface: ^5.0.0
firebase_analytics: ^10.4.3
firebase_app_check: ^0.2.0
{
"authToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjE3MTYyOTA3MTc0NjgsImlkIjoiNjY0Yzg0OWNiMTc3ZmM3NDQ1MTBkMDhjIiwicm9sZSI6ImN1c3RvbWVyIiwiaWF0IjoxNzE2MjkwNzE3LCJleHAiOjE3MTYzNzcxMTd9.bOQnQxQNpuVDbSzghVvCBoXR5KfqcqOb4V7knWmdzWQ",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjE3MTYyOTA3MTc0NjgsImlkIjoiNjY0Yzg0OWNiMTc3ZmM3NDQ1MTBkMDhjIiwicm9sZSI6ImN1c3RvbWVyIiwiaWF0IjoxNzE2MjkwNzE3LCJleHAiOjE3MTY4OTU1MTd9.72vt4gnLPbczRL3eNd5VBY-65jVFFb6S1kT9Z0uEatI",
"firebaseUser": {
"uid": "664c849cb177fc744510d08c",
"email": "[email protected]",
"emailVerified": false,
"displayName": "meihdi mettag",
"disabled": false,
"metadata": {
"lastSignInTime": null,
"creationTime": "Tue, 21 May 2024 11:25:16 GMT",
"lastRefreshTime": null
},
"tokensValidAfterTime": "Tue, 21 May 2024 11:25:16 GMT",
"providerData": [{
"uid": "[email protected]",
"displayName": "meihdi mettag",
"email": "[email protected]",
"providerId": "password"
}]
}
}
try {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
print("Firebase initialized successfully.");
} catch (e) {
print("Error initializing Firebase: $e");
}
try {
await FirebaseAppCheck.instance.activate(
webProvider: ReCaptchaV3Provider('xxxxxxxxxxxxxxxxxx'),
androidProvider: AndroidProvider.debug,
appleProvider: AppleProvider.appAttest,
);
print("Firebase App Check activated successfully.");
} catch (e) {
print("Error activating Firebase App Check: $e");
}
authenticateBasic(Map<String, dynamic> userData) async {
print("USERDATA");
print(userData);
UserModel userModel = UserModel.fromJson(userData);
await FirebaseAuth.instance.signInWithCustomToken(userData["authToken"]);
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString("access_token", userData["accessToken"]);
//update one signal id
var userOneSignalId = await OneSignal.shared.getDeviceState();
await UserAPI().updateUser({"notificationToken": userOneSignalId!.userId},
FirebaseAuth.instance.currentUser!.uid);
usermodel.value = userModel;
return userModel;
}
However, when I register, I get an error message from my app even though the user is registered on Firebase Auth and in my database. When I try to connect, the app returns a null error because FirebaseAuth.instance.currentUser.uid is null.
Has anyone encountered this issue before or can provide some insights on how to resolve this?
Thank you in advance for your help!
What I Have Tried
Updated my JSON files:
I updated the .json keys for Firebase configuration on both my server and my Flutter application.
Tested Registration and Login:
I tried registering and logging in on my web application and compared the connection tokens. They are similar.
Modified Functions and Tested an Older Version of the App:
I modified my functions and even tested an older version of the app, but I still get the same error.