Firebase Admin SDK, FCM Cloud Messaging - node.js

I am using Firebase Admin SDK for cloud messaging and I have used GOOGLE_APPLICATION_CREDENTIALS, on Firebase I have added Android app, should I download Sdk file for that app and how can I test my notifications? Where should I get FCM token for test?

Are you using cloud shell to deploy the application? Here is a useful document by google on how o get the FCM token and how to setup the SDK [1]
[1] https://firebase.google.com/docs/cloud-messaging/android/first-message#retrieve-the-current-registration-token

Related

How do I implement authentication for Azure Mobile App in Xamarin.Forms using Apple signin

My app submission to the Apple Store got rejected because it requires users to log in though it does not implement Apple sign-in. My app is written in Xamarin.Form and uses Microsoft.Azure.Mobile.Client to communicate with my Azure Mobile App backend. It supports authentication with Facebook, Google, Twitter and Microsoft. For all those providers I use the "server flow". I followed some instructions I found on Apple sign-in here: https://learn.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/signinwithapple/
I got to the point where I get a userId and a token from the client but I am stuck on what to do next to enable authentication with the Azure Mobile App service.
Any help is greatly appreciated!
Thank you!

Bot works perfect in emulator but fails when deployed in test in webchat Send failed retry error

I have a C# echo bot developed in Visual Studio as per Azure documentation which runs successfully on a bot emulator in desktop. This bot was deployed to Azure and it wouldn't work in web chat or in the "Test in Web Chat" window in Azure portal. It always replies with - couldn't send retry. Could someone please help me out?
This post There was an error sending this message to your bot - Test in Web Chat suggested to check the Messaging endpoint specified and make sure it is same as your using in the bot emulator.
However messaging endpoint in Azure is like https://webappname123.azurewebsites.net/api/messages but in emulator endpoint is a local host http://localhost:3978/api/messages . How can these two match?
Also when I went into channels issue is like "There was an error sending this message to your bot: HTTP status code NotFound"
Is there any place where I could change endpoint URL?
I followed as it is process mentioned in Azure doc for building and deploying Echo bot
Have you added the correct Microsoft App ID and Microsoft App Password in your appsettings.json ?
Your Azure messaging endpoint in azure configuration should be the publicly accessible endpoint, when you are debugging locally, the emulator can authenticate using those Microsoft App ID and Microsoft App Password to reach your service.
When you deploy your solution your bot also authenticates using those credentials.
So make sure those credentials are correct and that your messaging endpoint "https://xxxxxx.azurewebsites.net/api/messages " is working publicly
When you publish your bot, there will be an option as below :
Select Edit App Service Settings.
Add the following details :
MicrosoftAppId : <xxxxx>
MicrosoftAppPassword : <xxxxx>
Click Apply, Ok.
Make sure you remove the Microsoft App Id and Microsoft App Password from appsettings.json, so that it works in bot emulator as well.
Now Publish the bot. It will work at both places.
Hope this is helpful.

authentication in mobile app with azure functions

I am trying to develop a serverless backend for my xamarin app. and for that I chose azure functions.
Now I already know that Azure Mobile Apps provide an SDK for this purpose with which we can easily enable Authentication with multiple ways which are following
1. Azure Active Directiry
2. Facebook
3. Google
4. Microsoft
5. Twitter
Now I want to allow login with atleast 2 of these in my app, but I am not using azure mobile app as backend, instead I am using azure functions. So how can I achieve the same result with serverless?
Thanks in advance.
AFAIK, when using Easy Auth (Authentication/Authorization in App Service), the user would be directed to {your-app-service-url}/.auth/login/{provider} for logging with Server-managed authentication. Users who interact with your web application through the web browser would have a cookie and they can remain authenticated as the browser your web application. For other clients (e.g. mobile client), a JWT would be contained in the x-zumo-auth header, and the Mobile Apps client SDK would handle it for you.
According to your scenario, you are trying to use user-based authentication with your function. I did some test, you could refer to them:
Firstly, I created a HttpTrigger function wrote in C#, then set the Authorization level to Anonymous.
return req.CreateResponse(HttpStatusCode.OK, req.Headers,JsonMediaTypeFormatter.DefaultMediaType);
Note: I just return all headers with the special headers specified by App Service Authentication / Authentication. Some example headers include:
X-MS-CLIENT-PRINCIPAL-NAME
X-MS-CLIENT-PRINCIPAL-ID
X-MS-TOKEN-MICROSOFTACCOUNT-ACCESS-TOKEN
X-MS-TOKEN-MICROSOFTACCOUNT-EXPIRES-ON
For more details, you could refer to App Service Token Store.
Then I go to Platform features and configure the Microsoft Authentication Provider under Authentication / Authorization. For mobile client, just use the Mobile Apps client SDK for logging and invoke the function endpoint as follows:
In summary, you could use the Mobile Apps client SDK for authentication with your function app. And you could configure the Authentication Providers as you wish, then for your mobile client you could set the related provider name when calling LoginAsync for logging. For your function, you could check the X-MS-CLIENT-PRINCIPAL-IDP header and retrieve the current user info and token for the specific provider.
Since Azure Functions are built on top of App Services, like Mobile Apps, you can still use Azure Active Directory authentication or the API keys for the Http triggered functions.

Firebase Admin when I add a user email is anonymous

IM using the new firebase admin SDK for node js and I created an api where I can add users. Everything is working fine but when I see a new user in my firebase dashboard I find Anonymous.
When you create a custom authentication token with Firebase Admin SDK, those users are not shown in the Firebase Authentication console.

How to store account information in Xamarin.iOS Azure Mobile App?

I use Twitter to authenticate users in an Azure Mobile App. I want to save the account information on the phone so that users don't have to log in each time the app starts. It's a Xamarin.iOS app.
If I were building a Windows app, I'd use PasswordVault as explained in the Azure Mobile Apps documentation under "Caching the authentication token".
If I were using Xamarin.Auth, I'd use the AccountStore as explained in the Xamarin.Auth documentation under "Storing and Retrieving Account Information on Devices".
I see that the Azure Mobile App SDK contains a modified version of the Xamarin.Auth plugin. Can I use the AccountStore that way?
If not, what's the best way to save account information in Xamarin.iOS?
The answer is to use the iOS Keychain. I forgot that Xamarin.Auth is open source. Here's how it stores accounts:
https://github.com/xamarin/Xamarin.Auth/blob/master/src/Xamarin.Auth.iOS/KeyChainAccountStore.cs
There's also a Keychain sample from Xamarin:
https://github.com/xamarin/monotouch-samples/blob/master/Keychain/Main.cs

Resources