Comments (4)
The author may have a more general solution, but I'll go ahead and put in my two cents.
Since you're using Xamarin, you can use the AccountStore in the Xamarin.Auth package:
Github
Docs
When saving, you can add your own properties to the account. For example, I have a CredentialsService class with a property to save the FirebaseAuth json:
public string FirebaseAuthJson
{
get
{
return _account?.Properties["FirebaseAuthJson"];
}
set
{
if(_account != null)
{
_account.Properties["FirebaseAuthJson"] = value;
AccountStore.Create().Save(_account, SERVICE_ID);
}
}
}
So you can set it like this:
string json = JsonConvert.SerializeObject(firebaseAuth);
credentialsService.FirebaseAuthJson = json;
And retrieve like this:
var account = AccountStore.Create().FindAccountsForService(App.AppName).FirstOrDefault();
if(account == null)
{
SignInAnonymously();
}
else
{
string json = account.Properties ["FirebaseAuthJson"];
FirebaseAuth auth = JsonConvert.DeserializeObject<FirebaseAuth>(json);
var authProvider = new FirebaseAuthProvider(new FirebaseConfig(Config.ApiKeys.FIREBASE));
FirebaseAuthLink authLink = new FirebaseAuthLink(authProvider, auth);
...
// Now you can do some more verification
}
from firebase-authentication-dotnet.
That's pretty much what I do - I save the user information into storage (ApplicationDataContainer
in UWP) and during startup I check if there is any info there.
from firebase-authentication-dotnet.
thats not a correct approach, i believe. FirebaseToken is a JWT and it contains expiry date information or even though sigin functions have expiry date information. you should verify that it is not expired. if expired refresh token. even though, token can be invalidated for different reason before expiry dates. for example, if user changes, his password or deleting account on other device etc. better to always user verify token function. it doesnt have to be because if token is invalid, other actions like database access will return an exception. but at least do offline expiry date check
from firebase-authentication-dotnet.
@EmilAlipiev You're correct. My answer was outdated. You have to save the whole FirebaseAuth object because it contains the needed info for refreshing. And yes, it's good to do extra verification after the auth object is retrieved.
I edited my previous reply to reflect these points.
from firebase-authentication-dotnet.
Related Issues (20)
- (Enchancement) Support Local Storage & Async for IUserRepository HOT 1
- Possibility to check user password HOT 1
- Question: do you not support sign in with custom token? HOT 1
- Email verification HOT 7
- Posibility to change the token expiration HOT 1
- Phone Authentication
- Exception occured during Firebase Http request. HOT 1
- Check if DisplayName already exists HOT 1
- Need Help with login with Google in .NET MAUI HOT 1
- Email Verification Implementation Help HOT 1
- [Endpoints Migration] : identitytoolkit v3 needs to be migrated to something else HOT 1
- Is there a way to get the last time user logged in?
- Create Email and Password issue in .Net MAUI
- [.NET MAUI] How implement "OpenBrowserAndWaitForRedirectToAuthDomain" HOT 2
- I can't get FetchSignInMethodsForEmailAsync to work HOT 2
- How to persist authentication across app restarts ? HOT 6
- Allow FirebaseAuthConfig.RedirectUri to be configurable
- Observed in version 3.7.2 : Parsing error when the password ends (or maybe contains also) a backslash \ HOT 2
- How do you set a photo Url in version 4.1.0?
- Refresh Token Implementation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firebase-authentication-dotnet.