I'm struggling to configure two Firebase projects in one React Native app. I've successfully initialized the second app by following the instructions at Firebase Docs. But, when I use the secondary phone auth, it fails.
This is the error message on Android:
This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console. [ A safety_net_token was passed, but no matching SHA-256 was registered in the Firebase console. Please make sure that this application’s packageName/SHA256 pair is registered in the Firebase Console. ]
And this is the error message on iOS:
[Error: [auth/invalid-app-credential] Invalid token.]
In the Firebase Console of the second app, I've set up all credentials to identify clients:
iOS: p8 file to the Cloud Messaging tab, add URL schemes, ...
Android: SHA-1, and SHA-256 fingerprints
Is this implementation possible? Am I missing any step?
P/s: I also have created a new discussion in the rnfirebase Github repository: Link
Related
I'm trying to use expo notification service to create push notifications in my app. I followed the setup guide in the official docs: https://docs.expo.dev/push-notifications/push-notifications-setup/
However I'm getting the following error instead of getting the device token:
[Unhandled promise rejection: Error: Fetching the token failed: Please set your Project ID. A valid Firebase Project ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.Please refer to https://firebase.google.com/support/privacy/init-options.] at node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:106:59 in promiseMethodWrapper at node_modules/expo-modules-core/build/NativeModulesProxy.native.js:15:45 in moduleName.methodInfo.name at node_modules/expo-notifications/build/getDevicePushTokenAsync.js:15:69 in getDevicePushTokenAsync at node_modules/expo-notifications/build/getDevicePushTokenAsync.js:4:53 in getDevicePushTokenAsync at node_modules/expo-notifications/build/getExpoPushTokenAsync.js:9:85 in getExpoPushTokenAsync at node_modules/expo-notifications/build/getExpoPushTokenAsync.js:8:51 in getExpoPushTokenAsync
Environment info:
I'm using expo managed workflow. Expo on version 45.0.0.
`
It feels like I should configure my firebase project but I'm still running it on expo go and according to docs, I should only need to do that on build phase. I tried it anyway, but had no success. Also tried reading the provided link on the error and tried to change my firebase init options, but I'm not sure if I did it right.
We are using firebase phone authentication to authenticate our users. We've been using it for over a year now.
Today at 13:00 GMT, new users are receiving 17028 An invalid safety_net_token was passed after entering their phone number.
I tried to verify each of the causes I found on the firebase docs:
Verifying the SHA1 and SHA256 on the firebase console (We use the fingerprints that are on the play store console)
Verifying the package name
The last app update was on October 1st and since then thousands of users created an account with Firebase Auth and there were no configuration changes on the firebase console.
Upon looking at other StackOverflow questions, the error we are getting is not the same as 17028 A safety_net_token was passed, but no matching SHA-256 was registered in the Firebase console. Please make sure that this application's packageName/SHA256 pair is registered in the Firebase Console Even though it is the same error code, in our case, it says an invalid token was passed.
We are using firebase with react-native-firebase module.
EDIT: After disabling Android device verification API from Google Cloud Console the verification is now working but with no device verification. (Users have to verify they're not robots with a CAPTCHA).
Update: It is working fine now, and the outage has been fixed.
It looks to be a firebase internal issue, and the only solution now is to disable "Android Device Verification" and all your users will see the Recaptcha page.
check
https://status.firebase.google.com/
https://status.firebase.google.com/incidents/TYeQBVB4kkzyk2kE8vbP
I have been trying and searching various methods to make Firebase Phone Auth to work in my flutter application. (There is an open issue talking about conflicts between Firebase Cloud Messaging & Firebase Phone Auth, but I am unsure if my issue is related to that. I do use Firebase Cloud Messaging which works perfectly fine.).
In iOS simulator, whenever I call FirebaseAuth.instance.verifyPhoneNumber, my app opens a web page for reCAPTCHA workflow, and returns back to the app. Then I see the error logs like below in verificationFailed callback. (It is expected to follow reCAPTCHA flow for iOS Simulator according to Firebase Phone Auth Doc)
flutter: Instance of 'AuthException'
flutter: {"error":{"code":403,"message":"Requests from this ios client application <empty> are blocked.","errors":[{"message":"Requests from this ios client application <empty> are blocked.","domain":"global","reason":"forbidden"}],"status":"PERMISSION_DENIED"}}
It is suspicious that error message is using <empty> as my application name, instead of my real app name (or default firebase app name which is __FIRAPP_DEFAULT), but I am unsure why that is happening.
In real iOS device, whenever I call FirebaseAuth.instance.verifyPhoneNumber, the app invokes verificationFailed callback again and I get the error with verifyPhoneNumberError as code and Token mismatch as error message. This is happening in both debug build as well as in release build.
I am using following SDK & library versions.
Flutter SDK = 1.12.13+hotfix.5
firebase_core = 0.4.3
firebase_auth = 0.15.4
firebase_messaging = 6.0.9
Has anyone been able to get Firebase Auth Phone auth working in iOS? I am stuck in this limbo state because I cannot seem to search any info online related to this. I have setup iOS APN, GoogleService-info.plist, Google Cloud Credentials multiple times so far with no luck. (Given that Firebase Cloud Messaging works perfectly fine, I doubt it is an issue with credentials or APN setup.)
Answering my own question since I figured out the root cause.
In Google Cloud Project that is connected to Firebase, I was able to find a set of API Keys that were created by Firebase.
https://console.cloud.google.com/apis/credentials
For each App you define and create in Firebase, a new API key will be auto-created in the API key section. In my case, there was one for 'iOS key (auto created by Firebase)' and another for 'Android key (auto created by Firebase)'.
Well, by default, they do not impose any restrictions and you see a yellow triangle next to the key. So I added restrictions to those keys so that they can only be useable in my app. This is done by setting Application restrictions with corresponding bundle id for iOS and another app id for Android within each API key detail page.
This restriction was actually the reason that Phone Auth has not been working in my apps. Once I reverted the change back to None, I no longer encountered Token mismatch or AuthException.
Ideally, I should restrict these API keys to my app only, but it seems like my Flutter app is unable to prove its identity/appId/bundleId to google services, and Google had been rejecting requests from my App. This must be why I was seeing Requests from this ios client application <empty> are blocked. error message.
For now, everything is working because there is no restriction, but I will need to figure out why my app and its id association is not working as expected sooner than later, so that I can add restriction back.
I am testing some Firebase Cloud functions and when I test them locally using firebase functions:shell, I get this error:
#firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to
initializeApp() via the \"credential\" property failed to fetch a valid
Google OAuth2 access token with the following error: \"Error fetching
access token: Error while making request: getaddrinfo ENOTFOUND
metadata.google.internal metadata.google.internal:80. Error code:
ENOTFOUND\"."}
It seems to happen when I try to access admin.database() inside of the function.
These are my npm modules I'm using:
"dependencies": {
"firebase-admin": "^8.0.0",
"firebase-functions": "^3.1.0",
},
Is there something I'm missing here? I've tried uninstalling firebase-tools and reinstalling via npm i -g firebase-tools and that didn't help.
I'm also initializing the app via admin.initializeApp()
I had the same problem.
If you have a look at the Admin Authentication API Errors, you'll see the error app/invalid-credential is due to:
The credential used to authenticate the Admin SDKs cannot be used to perform the desired action. Certain Authentication methods such as createCustomToken() and verifyIdToken() require the SDK to be initialized with a certificate credential as opposed to a refresh token or Application Default credential. See Initialize the SDK for documentation on how to authenticate the Admin SDKs with a certificate credential.
You need to manually specify your credentials.
To authenticate a service account and authorize it to access Firebase
services, you must generate a private key file in JSON format.
To generate a private key file for your service account:
In the Firebase console, open Settings > Service Accounts.
Click Generate New Private Key, then confirm by clicking Generate Key.
Securely store the JSON file containing the key.
I would recommend you to follow the instruction described in the section Initialize the SDK.
This solved the issue for me.
I am not able to send push message to iOS device from FCM console. I receive error message "Check APNs certificates in settings". My configuration is the same as in FCM guide:
I generated Auth Key in Apple Developer Account.
I uploaded auth key in Firebase project, put Key Id and prefix (Team Id).
I added FCM SDK to my iOS project (added Google-service.plist as well).
I saved registration token in Firebase Database.
Finally, I can send a message to all devices with my App ID (but cannot receive this message, I do not know why), but I cannot send a message to selected device with token.
Any ideas?
If the bundle ID that was used to generate the FCM token does not match the bundle ID in your Firebase App you will receive the error code: 'messaging/invalid-apns-credentials' even if your Auth key is configured correctly.
This seems like the most likely cause of this error ever occurring. Double and triple check that the FCM token was created by an app with the exact same bundle ID as what is listed in your Firebase console.
The GoogleServices-Info.plist does not verify that it contains the same Bundle ID as the app it is attached to so it is easy to make this mistake.
On the Android side you will get a compilation error if the appId is not present in your google-services.json thus preventing this issue.
Please check the app name in GoogleServices-Info.plist and Bundle ID in your app.
And also check you put the plist file in proper directory.
Uploaded auth key in Firebase project to both Dev and Prod ones.
This are the only reason for not having the push notfications to your app.