/firebase-authentication-dotnet

C# library for Firebase Authentication

Primary LanguageC#MIT LicenseMIT

FirebaseAuthentication.net

AppVeyor Build status

Firebase authentication library. It can generate Firebase auth token based on given OAuth token (issued by Google, Facebook...). This Firebase token can then be used with REST queries against Firebase Database endpoints. See FirebaseDatabase.net for a C# library wrapping the Firebase Database REST queries.

Installation

// Install release version
Install-Package FirebaseAuthentication.net

Supported frameworks

Supported scenarios

  • Login with Google / Facebook / Github / Twitter OAuth tokens
  • Anonymous login
  • Login with email + password
  • Create new user with email + password
  • Send a password reset email
  • Link two accounts together

Usage

var authProvider = new FirebaseAuthProvider(new FirebaseConfig(FirebaseApiKey));
var facebookAccessToken = "<login with facebook and get oauth access token>";

var auth = await authProvider.SignInWithOAuthAsync(FirebaseAuthType.Facebook, facebookAccessToken);

var firebase = new FirebaseClient(
  "https://dinosaur-facts.firebaseio.com/",
  new FirebaseOptions
  {
    AuthTokenAsyncFactory = () => Task.FromResult(auth.FirebaseToken) 
  });

var dinos = await firebase
  .Child("dinosaurs")
  .OnceAsync<Dinosaur>();
  
foreach (var dino in dinos)
{
  Console.WriteLine($"{dino.Key} is {dino.Object.Height}m high.");
}

Facebook setup

Under Facebook developers page for your app make sure you have a similar setup:

Logo

Google setup

In the developer console make sure you have an OAuth client (set it either as iOS or Android app, that should work).