FusionAuth doesn't currently support the prompt=none
option for the authorization code grant. This is something we are planning on adding in one of the upcoming releases.
However, there is a work-around that others have used. You can make an AJAX request to the authorize endpoint of FusionAuth and then check the result to determine if the user needs to log in again or refresh their access token.
Here's how it works:
User not logged in
- Your application makes an AJAX request requests the /oauth2/authorize endpoint
- FusionAuth will respond with a 200 and HTML that contains our login form if the user is no longer logged in.
- Your application can check the response and see that the user needs to log in and take them to FusionAuth's interface to log back in.
User still logged in
- Your application makes an AJAX request requests the /oauth2/authorize endpoint
- FusionAuth will respond with a 302 to your
redirect_uri
with an authorization code
- Your backend will complete the authorization code grant and call the FusionAuth token endpoint
- This will return an access token (and possibly a refresh token)
- Your backend should return a 200 plus a JSON body or something that indicates the user is still logged in
- The AJAX response will be sent to your application and it can parse the response and see the user is still logged in
- Your application will now have the new access token
This flow works in AJAX nicely. It doesn't work well in an iframe
because there isn't a way for the iframe
to message back out to your application that either the user needs to log in again or they are still logged in and now have a new access token.
If you want to open a GitHub issue for the prompt=none
support on our authorize endpoint, you can do that here: https://github.com/FusionAuth/fusionauth-issues