Firebase functions library for C# to work with https.onCall
.
For Authenticating with Firebase checkout the Firebase Authentication library.
// Install release version
Install-Package FirebaseFunctions.net
- .NET Standard 1.1 - see https://github.com/dotnet/standard/blob/master/docs/versions.md for compatibility matrix.
- Firbase Functions
https.onCall
string FirebaseApiKey = "###########";
string FirebaseFunctions = "###########.cloudfunctions.net";
string FirebaseCallFunction = "Test";
var authProvider = new FirebaseAuthProvider(new FirebaseConfig(FirebaseApiKey));
var auth = await authProvider.SignInAnonymouslyAsync();
var functions = new FirebaseFunctions(FirebaseFunctions,
new FirebaseFunctionsOptions()
{
AuthTokenAsyncFactory = () => Task.FromResult(auth.FirebaseToken),
});
var function = functions.GetHttpsCallable(FirebaseCallFunction);
var response = await function.CallAsync();
Console.WriteLine($"Response: {response}");
exports.Test = functions.https.onCall((data, context) => {
// check request is made by an admin
if (context.auth.token.admin !== true) {
return { message: 'This user is not admin.' }
}
return {
message: `Admin success!`
}
});
This project is licensed under the MIT Licence.
Do you like this project? Please star this project on GitHub!