Question: I'm working on a very uncritical project. Therefore I want to have the best possible user experience while authentication meaning: log in once and stay logged in forever.

I managed to get firebase authentication working. However the token expires after one hour. 

I read that the refresh token never expires. (see [here](https://stackoverflow.com/questions/37907096/firebase-authentication-duration-is-too-persistent/37908468#37908468) ) Therefore I thought of putting it in the local storage and use it to retrieve a new access token. Is that correct?

If this was the case: why is there no 

```
this.afAuth.auth.getTokenWithRefreshToken()

```

Do I need to use 

```
this.afAuth.auth.signInWithCustomToken(MyRefreshTokenFromLocalStorage)

```

this function?

What does setting the persistence to LOCAL actually do? In the [docs](https://firebase.google.com/docs/auth/web/auth-state-persistence) it says you will be logged in forever (even if browser is closed and reopened) but thats not true? "This includes the ability to specify whether a signed in user should be indefinitely persisted until explicit sign out, cleared when the window is closed or cleared on page reload." (firebase docs)

I tried quite a few things including a third-party auth-provider but I never know if its not working or if I'm not smart enough. So if someone could give me a direction what might work and where I could focus my tries and errors I'd be super happy.

Answer: 
This thread says the problem is configuration in GCP <https://groups.google.com/g/firebase-talk/c/9q6jQKtZyEg> but does not elaborate

> 
> It turned out to be a GCP API configuration issue.
> The Token Service API must not be restricted, to allow the token to be refreshed.
> 
> 
> 

After more search, I got this <https://github.com/firebase/firebase-js-sdk/issues/497#issuecomment-375500476>

You need to add "Token Service API" to the list of restrictions for your API KEY in `APIs & Servicers/Credentials` at GCP console.
You do need to retrieve the refresh token yourself. [User.prototype.getIdToken](https://firebase.google.com/docs/reference/js/firebase.User#getIdToken) will check if the token expires, if no, it returns the token, otherwise, it uses the refresh token to exchange a new id token for you. 

For persistence, there is a doc here: <https://firebase.google.com/docs/auth/web/auth-state-persistence>

Local basically means the sign in states persist until you explicitly sign out and also the the states persist across tabs.