how to access Firebase from Google Cloud using Java? - java

here's my situation: I have my database in Firebase and my backend logic in Google Cloud, the code is in Java, apparently I can't even authenticate to Firebase because it requires the usage of the auth SDK available only for android (it's tied to Play Services).
What I need to do is, from Google Cloud AppEngine, get data from Firebase so I can manipulate it.
Thanks!

Use the Firebase Admin SDK to access your database from a server.

Related

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

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.

FCM with Cloud Datastore

I have a Java App Engine standard project (for about 4 years), using the Cloud Datastore (with Objectify). One of my services is using GCM to push notifications to mobile clients. Google has announced that GCM is deprecated and will be shut down 11th of April, and from then on Firebase messaging should be used instead of GCM.
After reading the docs it seemed straight forward to migrate, however I cannot create a Firebase database on my existing project, apparently I need to create a new App Engine project for this?
My question is, how can I use messaging on my existing App Engine project?
Starting a new project seems to me a bit overkill just to migrate from GCM to FCM.
Currently, once you select a database for your GCP project, you can't switch back. That's why you would have to create a new GCP project and a new App Engine.
I'm not very familiar with the Firebase products or the migration process from GCM to FCM, but if what you need is to switch from Cloud Datastore to Cloud Firestore, be aware that this change will be done automatically in the future.
You can also contact GCP support directly and request the upgrade.
I figured it out, I'm not able to create a new Firestore database, which is the "new" Firebase database currently in beta. This because I already using the Cloud Datastore in my current app engine project and cheese two cannot coexist whiten the same app engine project. However I was able to create a "old" Firebase database (real time database).
I don't really need a new database or my existing one migrated, I only need messaging to work (FCM) and using the Admin SDK the only way to initialise the library I need a database.

android - using firestore instead of auth

I want to make an android app that has users and everything related to it.
I just want to know if it is possible to use Firebase Firestore instead of Firebase Auth and if yes, how can I do that.
Any example would be appreciated and thanks in advance.
I just want to know if it is possible to use Firebase Firestore
instead of Firebase Auth
I'm assuming that you're asking to use Firebase Firestore instead of Firebase realtime database with Firebase Auth which is the current and stable version for that.
From the documentation:
Cloud Firestore is a flexible, scalable database for mobile, web, and
server development from Firebase and Google Cloud Platform. Like
Firebase Realtime Database, it keeps your data in sync across client
apps through realtime listeners and offers offline support for mobile
and web so you can build responsive apps that work regardless of
network latency or Internet connectivity. Cloud Firestore also offers
seamless integration with other Firebase and Google Cloud Platform
products, including Cloud Functions.
It's actually in beta release but you can use it.
Start using it with this link: https://firebase.google.com/docs/firestore/quickstart
And the available sample: https://github.com/firebase/quickstart-android/tree/master/firestore

How can I connect my Android Application to a database (and what should I be using)

So I am planning on creating a side project which is similar to Twitter, where the basic functions are to create accounts and store data such as username/password. And for users to create statuses and allow them to be visible on a 'news feed' so it should store the status in the database as well.
The front-end will be developed and designed for Android using Java, but how will I connect it to the database and what should I be using?
I recommend you to use firebase as a back-end database. It is very easy to learn and configure. For more info visit this link: Firebase

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

Categories

Resources