Shubhankar Pande
Shubhankar Pande

Reputation: 1

FirebaseAuthProvider could not be found

I am trying to add Firebase authentication to my .NET MAUI app and I am facing the following error :

Error CS0246 The type or namespace name 'FirebaseAuthProvider' could not be found (are you missing a using directive or an assembly reference?) EmailAuth (net8.0-android), EmailAuth (net8.0-ios), EmailAuth (net8.0-maccatalyst), EmailAuth (net8.0-windows10.0.19041.0) C:\Users\Sachin Pande\OneDrive\Documents\test_folder\EmailAuth\ViewModels\RegisterViewModel.cs 31 Active

Error CS0246 The type or namespace name 'FirebaseConfig' could not be found (are you missing a using directive or an assembly reference?) EmailAuth (net8.0-android), EmailAuth (net8.0-ios), EmailAuth (net8.0-maccatalyst), EmailAuth (net8.0-windows10.0.19041.0) C:\Users\Sachin Pande\OneDrive\Documents\test_folder\EmailAuth\ViewModels\RegisterViewModel.cs 31 Active

stating that FirebaseAuthProvider and FirebaseConfig could not be found.

I have added FirebaseAuthentication.net and Newtonsoft.Json packages to the project, and I am facing this error

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Firebase.Auth;



namespace EmailAuth.ViewModels
{
    internal class RegisterViewModel
    {
        public string webApiKey = "key";

        private INavigation _navigation;

        public Command RegisterUser { get;  }

        public RegisterViewModel(INavigation navigation)
        {
            this._navigation = navigation;

            RegisterUser = new Command(RegisterUserTappedAsync);
        }

        private async void RegisterUserTappedAsync(object obj)
        {
            try
            {
                var  authProvider = new FirebaseAuthProvider(new FirebaseConfig(webApiKey));
           
            }

            catch(Exception ex) 
            {
                await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "Ok");
                throw;
            }
        }
    }
}

enter image description here

Also if I use Firebase.Auth.Provider then I am getting following errors

enter image description here

How to figure out these error ?

Help will be appreciated!

Upvotes: 0

Views: 315

Answers (1)

user10627299
user10627299

Reputation: 9234

The usage of new FirebaseAuthProvider(new FirebaseConfig(webApiKey)); is appropriate for FirebaseAuthentication.net with 3.7.2 version.

So you can try to switch its version and change the using by following code:

Using Firebase.Auth;

About using the latest version of FirebaseAuthentication.net(4.1.0) to add Firebase authentication, you can refer to the official description in FirebaseAuthentication README.

Upvotes: 0

Related Questions