Google Auth giving "Request had insufficient authentication scopes" error while trying to run Google Script - firebase

I am trying to run my Google Script from within a cloud function from Firebase. When I run it, Google Auth is return an error saying Request had insufficient authentication scopes. I'm using the example from Google Quickstart found here: Google Apps Script Quickstart. My scope found in my token.json file is https://www.googleapis.com/auth/script.projects Is there something else I need to include just to run my simple script? Thanks in advance.

Related

Unable to call Firebase function from React.js application

I have a React.js application powered by a number of Firebase functions and real time database standing behind them. It has been working without any issue for the past 2-3 months and now I am getting a warning on the functions logs which says that:
#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: \"Failed to parse access token response: Error: Server responded with status 404.\"."}
The way I initialize firebase from my React.js application looks like this:
I have double-checked everything standing behind process.env and it seems to be as expected. The website written in React.js in hosted under the Firebase hosting.
And this is how Firebase functions connect to Admin SDK:
I am not sure what would be the issue here. Nothing has changes in the code base from our side. Not sure if Firebase changed something internally that we need to consider.
What solved the issue for me was to go to the google cloud console (where Firebase functions are also available). Then I opened one of the failing cloud functions and I navigated to
My_Function_Name/Edit/RUNTIME, BUILD AND CONNECTIONS SETTINGS/RUNTIME SERVICE ACCOUNT/
And then I noticed there that for all of my functions it was selected App Engine Default Service Account instead of Firebase Admin SDK. I never explicitly set the runtime to this option. So, when I brought it back to Firebase Admin SDK the error was gone I was able to use the application once again.

Google API requested! - Displayed in firebase serve

I have trouble authenticating my Google API and have no clue how to solve it. I want to get my Firestore document by using the REST api but it gives me no data at all in postman.
http://localhost:5000/<project-id>/us-central1/api/todos
I have tried this in my project dir and using cmd.
set GOOGLE_APPLICATION_CREDENTIALS="/functions/util/apikey.json"
But still no changes.
Below is my terminal that shows the warning.

Firebase: Why I am getting service worker registration error

I am trying to implement push messaging using firebase. For this, I have followed google doc as well as script that google shared on github. You can find the same on below URL:
Firebase Push Messaging Source Code
And also followed below tutorials:
JS Setup from Google Tutorial
How to Setup Push Messaging on Localhost
Below is my folder structure:
root
|--push-demo
| |
| |--index.html
| |--index.js
|
|--firebase-messaging-sw.js
I have followed everything that describes in all the above links. As per requirement, I have also done following things:
Enable SSL on localhost
Put firebase-messaging-sw.js in root folder
Path for all the included JS files are correct. I mean when I open them in browser, browser is showing me JS content.
Generated VAPID key from firebase console and used the same.
Also enable allow-insecure-localhost in chrome
After doing everything correctly, I am getting below error:
FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('https://localhost/firebase-cloud-messaging-push-scope') with script ('https://localhost/firebase-messaging-sw.js'): An SSL certificate error occurred when fetching the script. (messaging/failed-service-worker-registration).
Can someone please guide me about what is wrong at my side? I have looked many solutions on forums, and everyone is saying about either enable SSL on localhost or put your service file in root folder. But still I am getting error.
Thanks in advance.

Google Translate API authentication error

I am trying to call the Google Translate API and using the following to authenticate from my local - gcloud auth application-default login.
The command works successfully and I am authenticated but when I try to call the API i get the following error message which indicates that it is being read as an anonymous API call
google.cloud.exceptions.Forbidden: 403 Daily Limit Exceeded
I ran into this issue too this week,
I thought i was well authenticated but when i was running my code which is C# using the google translate API v2 package, it gave me the same 403 code daily limit exceeded,
I fiddled around with the CLI, made several accounts, service accounts API keys and all and it never worked.
https://cloud.google.com/dotnet/docs/getting-started/hello-world
this page, (the .NET guide part) says you should be using the google cloud platform plugin they release for visual studio, and login via that, i used it and it worked.
If you look on the bottom left part there are guides for any other language that you might be using. (consider adding that as info it helps me help you).
I would love it if it only worked via CLI but as long as it works i guess it's fine...

Where are the Firebase Access Denied messages logged on the server?

Where are the Firebase database rules "Access Denied" messages logged on the Firebase server?
We are using the JavaScript web version of Firebase client libraries. The answer below is referring to Android or iOS but can we get automatic logging / analytics on the Web version?
For example, one of our customers sees:
firebase issue Error: permission_denied at
/companydata/Global/eJztlD9PwzAQxb8K8pyBVqJDtkIpCtA/IpQFMRzJtbXq2NHlUhRV/e6ck4LKQioQagc23z3n+efn2Bs1JUx1AoyFCp83KmLM7rBSoZq7OVZWBWryWiCtgbWzjSK9JzAlynDs/IQcCdiRCs8DFRUTGczBFBioK2cZtEWK0lqcAqHlz64KbWmM/+beLQTC7Ck7h2hhHWGMQMlyqNGID1OJ22AfNVtQG+jsMj4F0hbKv0L0IAcSyrHrHx97s04r6Okn8vtfEmiF3JbjLeRg/6P8Pkqu8k5bkCNnsTobrfjLJjvHueSpy5ZtwP2yYAKj4UjAL4GKHbFw+XdfqhtyZb4rD01/oAkT3xFy7/jg3obaMNLOc5J7UQqVlBTO4oH67HXrZSxk2KiirD+eaplX8zEQ97ne+COsROpeSATk0jJhH0ivF6hry5qrceMzNXKbtu/y+E4I:
Client doesn't have permission to access the desired data.(…)
I'd like to see these errors in a log somewhere on the Firebase console.
Is there a place to see data rules denials?
Thanks!
There is no server-side location where these error messages are captured that you have access to.
You will have to reproduce the client's behavior locally or use the Firebase Database rules simulator to reproduce it.
I think that you have to do it (logging denied access), manually.
Firebase analytics collects some events by default. Here you can find the list of those events. And here is an example of how to add log events in android.

Resources