how to import JSON data from rest API to google firebase? - rest

I am planning to use Firebase as my backend service for the mobile application. As part of the functionality, I need to get the data from external rest API which returns JSON data. I need to update the data periodically so that I can have updated information.
I have an option to call the rest API and update firebase on the mobile application however it is not the right approach. I prefer to keep this logic on the backend service.
Is there a way to use Firebase cloud function to periodically update firebase database from external Rest API?

#Ioki, I assume what you are trying to do is make a mobile app which gets updated data every time a user goes to the app but you want this to be on the backend. I haven't tried it but you might want to use Node js with their Firebase Admin SDK.
See the link: https://firebase.google.com/docs/admin/setup
Although I think it might make more sense to use the real-time database via the iOS/ Android SDK because automatic/ value event updates are basically the purpose of the real- time database. Good luck! :)

Related

Looking for a secure way to store and read json file in serverless flutter using firebase

I'm making a mobile app using flutter and firebase.
To use Cloud Messaging of firebase, I need to send server key of firebase by putting in headers and sending with http post method.
headers: {
'Authorization': server key
}
However, it is not a recommended way to use server key. Firebase recommends to download json file of service account and use that file to get JWT token from firebase. Otherwise, I have to use Admin SDK and it's difficult for us because we don't have a backend server.
Therefore, my question is that are there any good ways to store json files in client side or local environment or firebase or Azure and can read the file only when we need it.
Plus, if you know the better way to send FCM from client side, please let me know. Thank you so much for reading it.
I have to use Admin SDK and it's difficult for us because we don't
have a backend server.
You can very well use the Admin SDK with Cloud Functions for Firebase, the "serverless framework that lets you run backend code". It is very common to use Cloud Functions to send message requests to the FCM backend, which then routes messages to client apps running on users' devices.
There is actually an official example that demonstrates how to send an FCM notification from a Realtime Database triggered Function. You can adapt it to be triggered by any other available trigger mechanism.

(dart / flutter) using "mongo_dart" for user authentication

I was developing a medical application (meaning I have to store patient information) with flutter as the frontend and mongoDB as the backend. Is it safe to use the "mongo_dart" package for signin / signup? Or must I use another package such as "http" and build a backend?
This is my first time building an authentication system, so I am really lost. When it is possible to use "mongo_dart" for authentication, how can I do so? Will I need to add a separate cluster for users, such that when an email and password matches I will grant user access?
First of all MongoDB is a database, it isn't a backend service. You can only store your data there.
The description of the "mongo_dart" starts with this sentence:
"Server-side driver library..."
So this package can be used for creating an API in dart. And also it is highly recommended to have an own backend service for your app.
So you can use Flutter for the frontend and MongoDB as your database service. Now you have to choose a language for backend, such as Node.js, Python or you can go with Dart as well.
And with your own API you could have an own API url, such as like: "https://myownpage.com/api/*". And in your Flutter app you can call this route for various actions: logging in, querying data and so on.
So it is absolutely fine to use all the things that you mentioned, but you have to create a backend application for the magic happening behind your mobile app.

User Management Token - React Native / MongoDB

I am new to react-native development. I need to implement User Authentication for Login and Sign Up for my react native apps. I saw some tutorial using Firebase Authentication but I plan to use the mongoDB instead of Firebase. I am not sure how to use mongoDB. For firebase its pretty simple because they provide API URLS and all we need to do is just send the request with our data. But when I am trying to use mongoDB I am not sure how to implement and get the token key back from server side. Do I need to write server side code for mongoDb or they have simplified API URL like firebase? Please Help . Thank You
You are missing a lot of concepts.
Firebase is a BaaS (Backend as a Service), so it sell you a backend already done with authentication, database ecc.
Mongo DB is a database, it could be IaaS (Infrastructure as a Service) or Paas (Platform as a Service), but it's not a BaaS.
So you can't just replace firebase with mongo, but you need to build your whole backend and have a server to deploy it. You need to manage environments, authentication, security and many other feature that firebase already offers you.

Cloud firestore sensitive information in .json file

In official Cloud Firestore documentation we can read that to connect with Cloud Firestore we need to download private key (.json) and use firebase-admin.
Is it safe to use that metod in client app? Or maybe there is other way to get safe access to Firestore from client app?
Thanks a lot.
As you said "private key (.json) , firebase-admin". These gives direct access to firestore database without authentication. If you don't want to make your client, admin of your firestore :) Don't do it.
Is it safe to use that metod in client app?
firebase-admin is not meant for use in web and mobile clients. It's for backend code running in an environment you fully control. Your users would not have access to this, which means it would be safe for you to use private keys.
You definitely do not want to ship any service account credentials with your app.
Or maybe there is other way to get safe access to Firestore from client app?
You're supposed to use the provided client SDKs to access Firestore from apps, and use security rules to declare which authenticated users are able to read and write which documents.

How can I access my database (mongodb mlab) directly from a react application without actually having to build an api?

There are tons of examples creating a react crud application using api, but I could not find one that directly access the database. Even when I continued with the api, I didn't know how to restrict people from using the api to delete and put data stored. Please help me and Thanks in advance.
Check out firebase. Here's a tutorial on integrating with React:
https://www.youtube.com/watch?v=mwNATxfUsgI
Firebase is a backend as a service. It won't let you access your mongo db database, but it will allow you to provide you with a databse