Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: A way to force token update when it becomes expired #59

Open
sallaben opened this issue Dec 24, 2020 · 6 comments
Open

Comments

@sallaben
Copy link

sallaben commented Dec 24, 2020

Hello! I am happy your solution is so much smaller. Do you know if there is a way to update the user object when the token expires? to run when expiry date < new Date()

I see a refresh token in user.tokenmanager, but not sure which method to call with that token, or if there's a parameterless method included with the firebase-auth-lite import.

fetchProfile doesn't seem to update the token, but maybe I need to await a svelte tick.

@sallaben
Copy link
Author

possibly related: #52, I will try this approach but I am still wondering about my original question

@samuelgozi
Copy link
Owner

samuelgozi commented Dec 24, 2020

Hi and thank you!
The library automatically refreshes tokens for you when needed if you use the auth.authorizedRequest method.
You can learn more about how it works here: https://github.com/samuelgozi/firebase-auth-lite/wiki/API-Reference#authorizedrequestresource-init

The gist of it is that auth.authorizedRequest should replace fetch for all requests that require authentication.
It has the same API as fetch, and actually, the only difference is that it adds the authorization header.

Please let me know if you have more questions.

@sallaben
Copy link
Author

sallaben commented Dec 24, 2020

The problem with authorizedRequest, though it is quite useful if I were using fetch, is that I would like to use axios instead of fetch API. How does authorizedRequest ensure it has an updated token? Maybe I could replicate that logic.

@samuelgozi
Copy link
Owner

Sorry for the delay in responses.
Please read this PR: #54
And let me know if it solves your problem.

@sallaben
Copy link
Author

sallaben commented Jan 1, 2021

thanks @samuelgozi and @ocruzv -- this is exactly the functionality I was hoping for!

Do we have an estimate on when the next npm release will happen? I'm happy to contribute code review or help in any other way if you have outstanding items to accomplish.

@samuelgozi
Copy link
Owner

The changes should be up in NPM. If not, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants