firebase error messaging/authentication-error - node.js

where does the server key go when using firebase nodejs sdk.
I'm getting the error messaging/authentication-error, message: 'An error occurred when trying to authenticate to the FCM servers. Make sure the credential used to authenticate this SDK has the proper permissions.
however my sdk works in when handling authentications, so it's definitely initialized just not for messaging.

Go to GCP Dashboard in your project;
Search API and Service;
In the Enable APIs and Services section, click +Enable APIs and Services, and search cloud messaging;
Now go to Cloud Messaging and Firebase Cloud Messaging API one by one and enable it.

Go to google cloud
then go to API and Services
then Enabled API and Services
then turn on the cloud messaging
Turn on Firebase cloud messaging API.

Related

An error occurred when trying to authenticate to the FCM servers. Make sure the credential used to authenticate this SDK [duplicate]

where does the server key go when using firebase nodejs sdk.
I'm getting the error messaging/authentication-error, message: 'An error occurred when trying to authenticate to the FCM servers. Make sure the credential used to authenticate this SDK has the proper permissions.
however my sdk works in when handling authentications, so it's definitely initialized just not for messaging.
Go to GCP Dashboard in your project;
Search API and Service;
In the Enable APIs and Services section, click +Enable APIs and Services, and search cloud messaging;
Now go to Cloud Messaging and Firebase Cloud Messaging API one by one and enable it.
Go to google cloud
then go to API and Services
then Enabled API and Services
then turn on the cloud messaging
Turn on Firebase cloud messaging API.

Is it good practice to have a React Native app Publish directly to a Google Pub/Sub topic?

We are building a serverless platform consisting of Android and iOS apps build using React Native and on the backend we use Google Cloud Functions and Firebase. Given that some actions are handled by multiple Cloud Functions, we thought it would be a good idea to have the apps Publish to a Pub/Sub topic and then have the different Cloud Functions fire Subscribe events when the apps publish. Is it good practice to have a React Native app Publish directly to a Google Pub/Sub topic or should we have an HTTPS Cloud Function do the topic publishing?
If it is good practice for the apps to do the Pub/Sub, any tips on how to handle the credentials? There is a Node.js client but not a React Native one in particular. The main issue seems to be with the environmental variable you are supposed to set (e.g. export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/[FILE_NAME].json").
Thanks!
If you are going to communicate with firebase (or any server) from the client´s device, best practice is so that you use clients authentication, and not some secure token for all.
There is the benefit, that firebase comes with client authentication.
I would look into 2 ways.
use firebase directly as a queue. it´s actually capable of doing that just fine and comes automatically with firebase authentication. (see https://github.com/firebase/firebase-queue)
use firebase cloud functions. The benefit is, authentication is automatically included if you logged in the user with firebase authentication. From there, you can write a simple cloud function to add data to your queue. (see https://firebase.google.com/docs/functions/callable)

How to connect a Xamarin app to a SQL Azure DB

I have created an SQL Azure DB and I want to connect a new Xamarin app that's supposed to run on Android, to it.
I am new to Xamarin an I couldn't figure out a simple way to do it from the tutorials online.
What's the simplest way to fetch data from a SQL DB in Azure, using Xamarin app?
Answer
You'll need to create an Azure API App. The Xamarin app will use this REST API to interact with the database.
Never connect a mobile app directly to a remote database using the database's connection string, because this opens up the potential for database corruption. For example, if the mobile app user has a poor internet connection, and they are connecting directly to the database, the app may not be able to finish executing a database query. An API will ensure that no database corruption happens due to a poor internet connection.
Sample Code + Walkthrough
I have a sample app and a walkthrough here that shows how to create an Azure API App, connect it to an Azure SQL Database and how to have the mobile app communicate with the REST API.
https://github.com/brminnick/XamList
Per my understanding, you could leverage the Data access and Client SDKs
features provided by Mobile Apps in Azure App Service for a simple way to achieve your purpose. You could follow the tutorials below for getting started with the Azure mobile app:
Sign in Azure portal, Create an Azure Mobile App backend
Add your data connection and link to your SQL Azure DB, for more details you could refer to Configure the server project
Download and run the Xamarin.Android app working with your SQL Azure DB
Additionally, you could refer to Adrian hall's book develop-mobile-apps-with-csharp-and-azure for a better understanding of Azure mobile apps.

Data Flow for Azure Backend on Native Android Apps

We are looking at using Azure for the backend for our native Android application. The application will have user accounts along with product information and order history information. The idea is to manage the user, product, and order information in the Azure backend.
Could you help confirm if my understanding is correct on the following:
There are three components involved: native Android app on client side, Node.js app on the server side, and Azure Storage.
The Node.js app on the server side is where for example get/set user/product/order API calls are implemented
Backend implementation is offered via Node.js or .NET via SDK, but for other implementations can also be done via REST calls to Azure
storage
The data flow involved is: Android app communicates to Node.js app via REST API, while Node.js app communicates to Azure Storage via SDK
(or REST API).
If you could help confirm these, it would be greatly appreciated
Mobile Apps is the mobile-backend-as-a-service which have the API consisted of standard HTTP verbs (GET, POST, etc). Every HTTP verb has the script associated with that that can be written using C#/Node.js on the backend side. That code is being executed every time that HTTP verb is "executed" by the client. Client can have whatever he wants in terms of language/platform.
There are three components involved: native Android app on client side, Node.js >app on the server side, and Azure Storage.
It depends on what you are using. If Mobile Apps, then there is SQL Azure. If not - then you can use Storage, SQL or whatever you need.
The Node.js app on the server side is where for example get/set >user/product/order API calls are implemented
Node.js in Mobile Apps are implemented as the scripts that are executed when there is some HTTP method invoked by the client. For example, you are able to implement the PUSH notification if client invokes POST HTTP method and insert some entity into the storage backend using Mobile Apps.
Backend implementation is offered via Node.js or .NET via SDK, but for other >implementations can also be done via REST calls to Azure storage
Yes. But again, if you mean Mobile Apps (i think you do), then it is SQL Azure, and here you can use SQL Server Management Studio, Visual Studio or something else to manage the SQL Azure DB. Or use REST API.
The data flow involved is: Android app communicates to Node.js app via REST API, >while Node.js app communicates to Azure Storage via SDK (or REST API).
Node.js backend communicates with the storage backend using modules that you can add (for example, SendGrid to send SMS or store the blobs in the Storage) and some underlying technologies and adapters.

How to use my own API instead of using mobile API in Azure

is there any way to publish my API in azure mobile service API instead of using its own. I want just to know it, because assume I have a backup server in amazon and as you know I don't have access to azure sdk in there and it means technically I cant use the API anywhere outside the azure.
Azure mobile services is actually based on the .Net web api in their C# flavor and on node.js on the Javascript side. You could surely write an API using those technology and have the same behavior. You will gain the fact of being more portable, however you will lose some of the preconfigured stuff from Mobile services.
If you are using .NET, please check this to see how to build a Web api! http://www.asp.net/web-api.
If you are using Javascript, here is where you should start : https://nodejs.org/
Both tech are quite easy to learn and super powerfull, have fun! When your API is built, you could just publish them as an azure Web APP (http://azure.microsoft.com/en-us/services/app-service/web/) or an Azure API (https://azure.microsoft.com/en-us/services/app-service/api/) instead of the mobile App
Hope it helps, if you have more questions, please ask!
You can create and publish your own custom APIs in azure mobile service. You could even access in via azure mobile service sdk in client by using "InvokeApiAsync<>()" method.
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn614130.aspx
If you want to access the api via fidder/httpclient than AZM SDK, pass the mobile service key in HTTP header as Name:'x-zumo-application' value:'application key from portal'

Resources