Google Cloud Debugger not working on Node.js - node.js

My Node.js API service is hosted on google cloud App Engine running in a standard environment.
I have followed all the steps but the following message is being thrown by the debug agent:
#google-cloud/debug-agent Failed to re-register debuggee xxx-backend: Error: The file at { does not exist, or it is not a file. ENOENT: no such file or directory, lstat '/workspace/{'
I have this code at the top of my app.ts file:
require('#google-cloud/debug-agent').start();
My Node.js version is: 14.17.0
After updating the package and installing it again the error is:
Error: The file at { does not exist, or it is not a file. ENOENT: no such file or directory, lstat '/workspace/{' at Object.realpathSync (fs.js:1796:7) at GoogleAuth._getApplicationCredentialsFromFilePath (/workspace/node_modules/google-auth-library/build/src/auth/googleauth.js:263:27) at GoogleAuth._tryGetApplicationCredentialsFromEnvironmentVariable (/workspace/node_modules/google-auth-library/build/src/auth/googleauth.js:206:25) at GoogleAuth.getApplicationDefaultAsync (/workspace/node_modules/google-auth-library/build/src/auth/googleauth.js:136:24) at GoogleAuth.getClient (/workspace/node_modules/google-auth-library/build/src/auth/googleauth.js:551:28) at GrpcClient._getCredentials (/workspace/node_modules/#google-cloud/logging/node_modules/google-gax/build/src/grpc.js:145:40) at GrpcClient.createStub (/workspace/node_modules/#google-cloud/logging/node_modules/google-gax/build/src/grpc.js:308:34) at processTicksAndRejections (internal/process/task_queues.js:95:5)

The environment variable GOOGLE_APPLICATION_CREDENTIALS is used to provide authentication credentials to your application code.
The Stackdriver Debugger Agent should work without manually provided authentication credentials for instances running on Google Cloud Platform, if the Stackdriver Debugger API access scope is enabled on that instance. For Google App Engine instances, this is automatic if the Debugger API has been enabled for your project (which is the default). If you are running elsewhere such as locally, on-premise, or on another cloud provider, you need to manually provide credentials. For more information refer to the documentation.
You were setting the env variable GOOGLE_APPLICATION_CREDENTIALS to the file “{” that’s why you were getting an error.
Looks like you are running the code on Google Cloud Platform that's the reason your code is working even after deleting the
env variable GOOGLE_APPLICATION_CREDENTIALS.

Okay, so I got the answer by trying out some stuff. Basically, I had GOOGLE_APPLICATION_CREDENTIALS in my secrets.
My application is deployed in GAE so I don't need the credentials. I was using another application for hosting before so I had it in my secrets.
Once I removed that secret it started to work.
But why did this error occur? The credentials were correct so it should have worked anyway right?

Related

Google Maps JavaScript API warning: InvalidKey and Google Maps JavaScript API error: InvalidKeyMapError

I am trying to deploy an open source project (https://github.com/LiteFarmOrg/LiteFarm) on local host through docker composer and i have followed the instructions provided in the link, the app is a node.js app with frontend in react.js i have provided the (google_api_key) for the map to work in the application in the ".env" file but i am getting the error of "invalidkey" yet i tried to provide another newly generated key same error i faced. the screenshot is as
invalid key error
also in the location text field the "icon of something went wrong is coming".

GCloud Vision API Permission Denied on Second Request

I've gone through all the setup steps to make calls to the Google Vision API from a Node.js App. Link to the guide: https://cloud.google.com/vision/docs/libraries#setting_up_authentication
I'm using the ImageAnnotatorClient from the #google-cloud/vision package to make some text detections.
At first, it looked like everything was set up correctly but I don't know why it only allows me to do one request.
Further requests will give me the following error:
Error: 7 PERMISSION_DENIED: Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the vision.googleapis.com. We recommend configuring the billing/quota_project setting in gcloud or using a service account through the auth/impersonate_service_account setting. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/
If I restart the Node app it again allows me to do one request to the Vision API but then the subsequent requests keep failing.
Here's my code which is almost the same as in the examples:
const vision = require('#google-cloud/vision');
// Creates a client
const client = new vision.ImageAnnotatorClient();
const detectText = async (imgPath) => {
// console.log(imgPath);
const [result] = await client.textDetection(imgPath);
const detections = result.textAnnotations;
return detections;
}
It is worth to mention that this works every time when I run the Node app in my local machine. The problem is happening on my Ubuntu Droplet from Digital Ocean.
Again, I set everything up as it is in the guides. Created a Service Account, downloaded the Service Account Key JSON file, set up the environment variable like this:
export GOOGLE_APPLICATION_CREDENTIALS="PATH-TO-JSON-FILE"
I'm also setting the environment variable in the .bashrc file.
What could I be missing? Before setting up everything from scratch and go through the whole process again I thought it would be good to ask for some help.
So I found the problem. In my case, it was a problem with PM2 not passing the system env variables to the Node app.
So I had everything set up correctly auth-wise but the Node app wasn't seeing the GOOGLE_APPLICATION_CREDENTIALS env var.
I deleted the PM2 process, created a new one and now it works.

Google Firebase: HTTP Error: 401, The entered credentials were incorrect

I am just getting started with Firebase. I logged in using firebase login and it says I am logged in. I used firebase init to create a new project, used hosting option, and used the default firebase application. When I went to deploy using firebase deploy it said "The entered credentials were incorrect".
I'm not sure where I went wrong. To set up, I used brew install npm and then npm install -g firebase-tools (I'm on a mac).
I found some posts saying the project ID could be incorrect in the .firebaserc file, but it looks correct when compared to the firebase list output.
It looks like the default HTML that was generated will probably work, but it just won't deploy!
I found my own answer for this. When you tell it to use the default project, if you say firebase deploy, it tries to deploy to the default project's host system.
To fix it, create a project on the firebase server, init the firebase project (pointed at the new project name) and that will allow you to push to the server.

Autodesk Forge API a-401 Error

I'm trying to make a simple forge test work.
I am been using this basic git project:
https://github.com/leefsmp/view.and.data-boilerplate
what i did so far:
i created an account.
implemented the creds in the config file
uploaded a file to models.autodesk.io using my secret key.
4 i took the udn and passed it into the viewer.js file.
ran npm install
npm run
when i go to the localhost:3000 i still get :
dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWwyMDE2LTExLTExLTEyLTQxLTA3LXlldmJwbHl0Yzkya3Y2cGtqdW10Z2F5ZnJ3dTAvUkEtUy1CdWlsZGluZy5ydnQ:1 GET https://developer.api.autodesk.com/viewingservice/v1/dXJuOmFkc2sub2JqZWN0cz…TEyLTQxLTA3LXlldmJwbHl0Yzkya3Y2cGtqdW10Z2F5ZnJ3dTAvUkEtUy1CdWlsZGluZy5ydnQ 401 (Unauthorized)
viewer.js:210 Access was denied to a network resource (HTTP 403).
The buttons for the load and unload extension are visible.
any ideas what i'm missing here?
I think you are looking at a deprecated repo, if you want to start with the use of boilerplate samples of the API this is a better option for you.
https://github.com/Autodesk-Forge/forge-boilers.nodejs

Error w/ Azure CLI on importing publish settings file

This is similar to the issue this SO user was having except I'm getting a different error for the same behavior.
I downloaded the publishsettings file from azure and
Issued this command in the azure cli: azure account import <MySite>.azurewebsites.net.PublishSettings
and I got the following error:
{ name: 'AssertionError',
message: undefined,
actual: 'UNIVERSAL-primative-0',
expected: 'UNIVERSAL-primative-6',
operator: '==' }
AssertionError: "UNIVERSAL-primative-0" == "UNIVERSAL-primative-6"
...Shortened for brevity. Let me know if you'd like the full stack trace...
I wasn't particularly anxious to wrap this node project in a VisualStudio project, but I think in a pinch, I could and just format the publish settings from within VS. But if there is a way to do this correctly, I'd prefer that.
Where did you get the file? Were you using the following command to get it?
azure site download
It seems like you are using the publishsettings file of an Azure Web Site while xplat-cli expects the publishsettings file of the subscription.
There are kinds of 2 publishsettings files. And yeah, it's confusing.

Resources