firebase Cloud task permissioned denied although giving all permissions to service accounts - javascript

I'm creating cloud tasks whenever new documentation got added to my firestore but cloud task invocation is failing with error permission denied "message: 'PERMISSION_DENIED(7): HTTP status code 403'"
Here is what I have done:
1- submitting new task (works)
2- task is failing with following error:
3- I have given all principles mentioned in the internet to selected below:
still failing!! any idea what I have missed ?
Thanks!!

After struggling days I found the issue.
Basically, the URL of the cloud task creation was not correct. I created the cloud function URL based on my firebase location (say europe-central2), however, the cloud function URL trigger should be taken from the cloud platform itself :) as following (as you can see it us-central link):

Related

TypeError in Firebase function does not log an Error in Logs Explorer

Using Firebase cloud functions with Javascript on a Blaze plan. Here are two log lines from Logs Explorer:
The function execution is stopped by a TypeError exception, but the associated logs respectively have the Default and Debug severity levels, making them hard to spot in the logs.
This prevents from using GCP's Error Reporting service to monitor Firebase cloud functions, since it would ignore these errors.
A workaround is to create a log based metric with a filter like
resource.type="cloud_function"
(severity>=ERROR OR textPayload:"finished with status: 'error'")
and to set an alarm with notifications on it.
Do you experience the same issue, should it be considered as a firebase functions bug?
This is a known issue, there exists a feature request for a similar issue in public issue tracker. Feel free to add your concern over this issue.

Why does a Cloud Function for Firebase (deployed without errors), throw "Uncaught (in promise) FirebaseError: internal" when called? [duplicate]

After months of developing a Web App under Firebase suddenly these days we have a problem with the Authentication, it returns this console.alert only with Facebook and google login (email/pass login works fine):
[firebase-auth] Info: The current domain is not authorized for OAuth
operations. This will prevent signInWithPopup, signInWithRedirect,
linkWithPopup and linkWithRedirect from working. Add your domain
(front.qualify.mx) to the OAuth redirect domains list in the Firebase
console -> Auth section -> Sign in method tab.
The App uses 3 different sub-domains, and in all 3 we can access over email/pass but not Facebook nor google.
We tried updating the Firebase initialization script, nothing. We have checked the API keys (in the Google APIs Credentials) and there was a new "Server key (auto created by Google Service)" which no one told us it was generated (Jan. 18th), so we edited it to include the domains as the original API key in different ways (w/wo * and /*), nothing. We deleted this new Server Key, suddenly something different, now the console includes a 403 error before the alert stated above and returns auth/timeout code inside the object.
We also found the Identity Toolkit API has detected many errors, so we tried to add the URLs for login, logout and email, but nothing happens when trying to save.
What are we missing?
The solution was adding my-app.firebaseapp.com (being my-app the unique identifier of our Firebase App) to the HTTP referrers in the Browser-Key Credentials from the Google APIs console and wait some time to propagate.
After many months of development the app never had a problem, and we are sure we never removed such referrer (if it was ever there).
Anyway... it's done and learned.
The simple way I was able to solve this issue I had with my ionic project was by following the instructions in the log, if you don't see any message try console log the response from firebase.
So what I simply did was follow the url: https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project='projectId'
*projectId = the Id of your project
and enable the Identity API something it brought up. Finish, and it worked instantly.

Firebase deploy: Missing expected firebase config value databaseURL

I'm trying to deploy my first function with firebase cloud functions.
I deployed the standard function "helloWorld" without problem, but then, when I added this:
const admin = require("firebase-admin");
admin.initializeApp();
firebase deploy didn't work anymore and caused this error:
Missing expected firebase config value databaseURL, config is actually{"projectId":"PROJECT-ID","storageBucket":"PROJECT-ID.appspot.com","locationId":"europe-west"}
If you are unit testing, please set process.env.FIREBASE_CONFIG
How can I set config or the value of databaseURL? I don't find anywhere the file where these things are written... I also looked in documentation but I didn't find anything useful
I tried also with
admin.initializeApp(process.env.FIREBASE_CONFIG);
but this give me this error:
Error: Error occurred while parsing your function triggers.
Error: Invalid Firebase app options passed as the first argument to initializeApp() for the app named "[DEFAULT]". Options must be a non-null object.
It looks like you're being affected by a change that was made a few months ago where the databaseURL is no longer auto-created when you create a new project.
If that is the case, you you can force the databaseURL to be generated by going to the Realtime Database panel in the Firebase console. If this indeed fixes the problem, it might be worth filing a bug report with the Firebase support team.
It looks like you don't have a default database created. Visit your firebase console and create at least one real-time database.
You can explicit select a database instance with functions.database.instance() View Docs

MongoDB: Can't connect to new replica set master

Trying to set up MongoDB for my Node.JS application. I running this command:
mongo "mongodb+srv://cluster0-gjc2u.mongodb.net/test" --username <myusername>
And getting this response every single time.
MongoDB shell version v4.2.1
Enter password:
connecting to: mongodb://cluster0-shard-00-00-gjc2u.mongodb.net:27017,cluster0-shard-00-01-gjc2u.mongodb.net:27017,cluster0-shard-00-02-gjc2u.mongodb.net:27017/test?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
2019-12-07T12:14:39.630-0600 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-gjc2u.mongodb.net:27017,cluster0-shard-00-01-gjc2u.mongodb.net:27017,cluster0-shard-00-02-gjc2u.mongodb.net:27017
2019-12-07T12:14:39.630-0600 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-00-gjc2u.mongodb.net:27017
2019-12-07T12:14:39.631-0600 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-01-gjc2u.mongodb.net:27017
2019-12-07T12:14:39.631-0600 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-02-gjc2u.mongodb.net:27017
2019-12-07T12:14:40.259-0600 I NETWORK [ReplicaSetMonitor-TaskExecutor] Confirmed replica set for Cluster0-shard-0 is Cluster0-shard-0/cluster0-shard-00-00-gjc2u.mongodb.net:27017,cluster0-shard-00-01-gjc2u.mongodb.net:27017,cluster0-shard-00-02-gjc2u.mongodb.net:27017
2019-12-07T12:14:40.799-0600 I NETWORK [js] Marking host cluster0-shard-00-00-gjc2u.mongodb.net:27017 as failed :: caused by :: Location40659: can't connect to new replica set master [cluster0-shard-00-00-gjc2u.mongodb.net:27017], err: AuthenticationFailed: bad auth Authentication failed.
*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.
2019-12-07T12:14:40.800-0600 E QUERY [js] Error: can't connect to new replica set master [cluster0-shard-00-00-gjc2u.mongodb.net:27017], err: AuthenticationFailed: bad auth Authentication failed. :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2019-12-07T12:14:40.803-0600 F - [main] exception: connect failed
2019-12-07T12:14:40.804-0600 E - [main] exiting with code 1
I have whitelisted my IP address and made sure everything is in order. What could be causing this problem and how could I fix it? Why would this problem be occurring?
What I tried was:
Create new user
Made sure the username and password for my mongoURI when connecting my application is the same as the username and password for when I connect with the mongo shell.
Run your connection string in your command line in your application.
I realise that "just wait a bit" isn't a terribly constructive answer, but I had the same issue and no luck in finding a solution, so left it for a couple hours and came back to find it working perfectly.
The text that says your change has been deployed is misleading. Not sure why it takes several hours to kick in, but for reference I found this when using the M0 Sandbox cluster tier.
So you have to take care of 2 things.
1) First off, having mongodb in your $PATH, create a .bash_profile under the home folder if you don't have it already, then insert the following.(For Ubuntu)
export PATH="$PATH:/usr/bin/mongo"
Make sure you place the location of mongo on your computer. If you don't know the location, type whereis mongo on the terminal.
After saving, type source ~/.bashrc in the terminal.
2) Lastly, copy the connect link from the mongodb atlas, and when asked for username and password
please provide the credentials set to access the database not the mongdb atlas account.
This resolution might be specific for the mLabs to MongoDB Atlas migration tool provided by Cloud MongoDB.
My resolution was to:
Re-create the user with the same user name
Change from spesific mLabs grants to Atlas built-in roles
Set new credentials, I also avoided using special chars.
Good luck!
Create a simple password which doesn't have any special characters, it only includes alphabets and numbers.
I wasn't able to access but changing password worked for me.

Accessing API in a function in a file in node.js and then deploying that file through firebase

I am new to firebase. I am trying to create a Weather bot on Dialogflow. But, firebase doesn't seem to be able to access openweather API when index.js file is deployed. At the same time this works just fine in Command prompt.
The following error occurs while executing
https.get("https://api.openweathermap.org/data/2.5/weather?q="+city+"&APPID={APPID}",function(response){...})
Error: Firebase.child failed: First argument was an invalid path: "undefined". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"
What's the problem here? How do I get around this?
function xyz(){
//Code
var https= require("https");
var city=London;
https.get("https://api.openweathermap.org/data/2.5/weather?q="+city+"&APPID={APPID}",function(response){
//Code
});
//Code
}
Google Cloud Functions doesn't allow to access Outbound networking calls to APIs other than that of Google Services in their free plan(Spark). If you want to make such call then you have to upgrade your plan. The fact that it is working on your local system is that local system allows making Outbound network calls to other services.
You can find more about pricing from here Google Pricing Plans
A small advice from my side is to use AWS Lambda if you don't want to pay and use it as free service to make Outbound networking calls.

Categories

Resources