- Notifications
You must be signed in to change notification settings - Fork 133
Open
Description
I have a maui app and in the class below to perform the Token refresh, but after a while, the user will be null
How can i prevent the app from loosing the User object? Is there something super basic I am missing?
This is on Windows
builder.Services.AddSingleton(new FirebaseAuthClient(new FirebaseAuthConfig() { ApiKey = "*****", AuthDomain = AppConfig.FirebaseAuth, Providers = new FirebaseAuthProvider[] { new EmailProvider() }, UserRepository = new FileUserRepository("EvolveFootballUser") })); public class FirebaseDatabaseClient { public FirebaseAuthClient AuthClient { get; set; } public FirebaseClient DatabaseClient { get; private set; } public UserService UserService { get; set; } public FirebaseDatabaseClient(FirebaseAuthClient authClient, UserService userService) { AuthClient = authClient; UserService = userService; DatabaseClient = new FirebaseClient( AppConfig.FireBaseDatabase, new FirebaseOptions { AuthTokenAsyncFactory = () => LoginAsync() }); } /// <summary> /// Retrieves (and refreshes if necessary) the current user's Firebase ID token. /// </summary> private async Task<string> LoginAsync() { if (AuthClient.User == null) throw new UnauthorizedAccessException("User is not authenticated."); // This forces a token refresh if the current one is expired or near expiry. var token = await AuthClient.User.GetIdTokenAsync(); return token; } }
Metadata
Metadata
Assignees
Labels
No labels