'When does identity.launchWebAuthFlow() complete silently?

I'm trying to use identity.launchWebAuthFlow() to run an OAuth2 flow from a Firefox extension. I find that sometimes, this function causes a popup to open where I have to log in to Google etc. and perform the authorization, but sometimes it just completes silently and my app works perfectly.

I looked it up at the docs linked above, and they say:

Note that if neither authentication or authorization are needed, then this function will complete silently, without any user interaction.

But how exactly (and this may be browser-dependent) does the browser determine whether or not authentication is "needed"? What state does it store? I'm confused because when you call this function, you get back (embedded inside a redirect URL) an access token, which has an expiry time (in my case of one hour). But I've noticed that launchWebAuthFlow() completes silently even after the access token is expires, so even if the browser is internally storing the access token and expiry time, it's still able to somehow do it.

This is specifically with Google's OAuth2 API (I haven't tested it with other APIs).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source