How to pass Google credentials for Vision Api in Node.js? - java

I'm trying to pass Google credentials (without service account json files) to allow my Google Cloud functions to make requests to the Google Cloud Vision Api.
One week ago I created an Java spring app engine project in the flexible container and here I was able to let my code access the Cloud Vision Api and the Cloud firestore without providing service account json files, because they run on the same project on Google cloud.
Now I'm trying to achieve the same in a Node.js project, because I'm splitting up the Java code into multiple cloud functions.
I already created a working version in Java Spring by using the following code. I have also managed to make a connection with Cloud firestore by providing a service account json file, but again not without that.
Version 1 - with service account file - Java
Credentials credentials = ServiceAccountCredentials.fromStream(new FileInputStream("path-to-json-file"));
Version 2 - without service account - Java
This version I need in my Node.js project
ImageAnnotatorSettings imageAnnotatorSettings =
ImageAnnotatorSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credentials))
.build();
I just want the Google cloud functions that run on the same project to be
automatically authenticated for the Cloud Vision API.

Related

Google Cloud Endpoints v2: Testing API key mechanism for an app-engine app executed on the local development machine

I'm a beginner in context of google-cloud-endpoints and the associated product "google-cloud-app-engine".
I've created a simple google app angine project/application and created an API-Key by using the google cloud platform's console.
To my app-engine's endpoints API definition I've added the annotation
"apiKeyRequired = AnnotationBoolean.TRUE" as stated in
Add API restriction by adding an API key to your app engine application
and my client application which uses the generated endpoints client API was also updated accordingly to send the generated API key for all API requests.
As I would like to test the "API-Key" mechanism locally on my development machine (using a local app-engine environment) before deploying the backend to the cloud, I would like to know, whether it is possible to test the "API-Key"-restrictions locally. I mean, somehow the locally executed app-engine backend app has to be aware of the created API key. Maybe there is a property which I have to provide to my app-engine backend application's POM.xml file...I don't know, whether the google app-engine SDK supports API keys for local testing in context of the "endpoints framework v2" actually. The newley introduced API Management Platform (API-Gateway) can maybe not be "simulated" locally...?!
Thank you so far for your effort!
API key restrictions should work locally. You just need to include GoogleAppEngineControlFilter in your web.xml.

Is it possible to host Java Spring application over Firebase hosting?

I am seeking information about using Firebase (as database) for Java. Is this possible along with hosting of Java (using Spring framework) project over Firebase hosting.
It is possible. Use Google App Engine an environment for running application code in the cloud; Platform as a service (PaaS).
Below is description how make to make basic example.
In the this tutorial, you'll learn how to:
Create a backend service running on App Engine using Android Studio.
Connect the backend service to your data in Firebase.
The sample app stores a to-do list in Firebase, which automatically synchronizes the data across devices, and then uses backend logic running on App Engine to send out daily reminder emails:
https://cloud.google.com/solutions/mobile/firebase-app-engine-android-studio
By connecting App Engine to a Firebase database, you can perform complex logic on data without having to manage synchronization and updates; Firebase handles that for you.
No. Firebase offers hosting for static assets only.
The Google Cloud Run seems is most suitable for what you want.
Consider to check the documentation and pricing. Like firebase, cloud run also has a free tier that can help you develop your app with no costs.
The cloud run supports several programming languages including Java.
Once created the service you can try to connect to your firebase project...
Cloud Run Java Documentation

sendgrid implementation without billing account in Google App Engine web project?

I am using sendgrid APIs to send bulk emails.We have cloud application in android and web using google app engine.As we know google app engine has limited quota.So we supposed to use FREE i.e.12k/month to send emails.We have integrated it properly.If I run the code at local side i.e. localhost:888, it works but if I deploy the code and try it from there then I am getting below exception.I have created an account on sendgrid already and verified as well.
com.google.apphosting.api.ApiProxy$FeatureNotEnabledException: The
Socket API will be enabled for this application once billing has been
enabled in the admin console
Is it really needed to have billing account?
You can use sendgrids web api which does not require the Socket API in App Engine.
If you want to use sendgrid's SMTP API you will have to enable billing. I would recommend using the web api though.
They have an example i successfully use in one of my projects.

How to fetch values from GAE datastore to android application ?

I'm creating a network based android application. So
1) I've installed Google App Engine Plugin in eclipse IDE and start developing a network based android applications where all information of customers are stored in GAE Datastore.
2) I've created a new Web-Application and stored Entities in datastore. Can i retrieve those values and show in my android application and add new details in from my application to GAE Datastore.
Please Help Me, I'm new to Web Service, SOAP, REST, JSON etc.
Can anyone tell me a simple method to store and fetch values from Cloud DB to Android App.
There are two apparent options:
Use Cloud Endpoints. They are proprietary and not my favourite. Also they are only available for Android, iOS and JS.
Use web services, my favourite would be JAX-RS, specifically RESTEasy+Jackson. See this GAE example and simple Android client.

how to add azure web role using rest api

I have accomplished deploying a java web/worker role using Azure SDK for Eclipse with the help of the following site : http://dotnetslackers.com/articles/net/Developing-a-Hello-World-Java-Application-and-Deploying-it-in-Windows-Azure1.aspx
Are there options to deploy a java web/worker role using REST APIs of Azure.
Thanks in advance
Yes there is.
From this tutorial you've learned how to directly deploy your application (web role) to Windows Azure. The Windows Azure Tools plugin for Eclipse have one more option - create package. If you just create a package you can use it to later deploy it as Cloud Service (that is the web/worker role) via REST API or PowerShell cmdlets.
However the process of using REST API will be a two step process:
You upload your package to an Azure blob storage using the BLOB REST API.
Create a production deployment for your cloud service pointing the correct package URI in the blob. Do this by using the Azure Management REST API - Create Deployment operation;
Note that the REST Management API for Azure is using client certificate for authentication, which you first have to upload via the management portal.

Categories

Resources