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

Refresh token not available after initial login. #2574

Open
mark-robustelli opened this issue Dec 8, 2023 · 9 comments
Open

Refresh token not available after initial login. #2574

mark-robustelli opened this issue Dec 8, 2023 · 9 comments
Labels
documentation An issue or clarification on documentation

Comments

@mark-robustelli
Copy link

Refresh token not available after initial login.

Description

When using Google Login, the refesh token is not always available in the Access Token Response. It is available the first time the user logs into the application but not in subsequent logins. This was discovered in this this community thread.

Affects versions

Currently tested with 1.48.1

Steps to reproduce

Steps to reproduce the behavior:

  1. Create an Application and enable debugging. I used fusionauth-quickstart-dotnet-web as a base.
    01 - application

  2. Set up the application in Google
    02 - google setup

  3. Create and Open ID Connect Identity Provider and enable if for the application

    • Need to do this so you can supply the access_type=offline to the Authorization endpoint.
      05 - Open ID connect with access_type equal offline
  4. Login to the application using the Open ID Connect button.
    10 - login

  5. Choose your Google account.
    15 account

  6. Consent to access.
    20 Consent

  7. View the debug log and you can view the refresh token
    25 See Refresh Token

  8. Logout of Application.
    30 - logout

  9. Log back into Application using the Open ID Connect button.

  10. Look at the logs and see there is now no refresh token.
    35 - no refresh token

  11. Log out.

  12. Go into the Google account you are using to test with and remove all connections with the test application.
    40 - Delete all connections in google

  13. Go to web application and login again using Open Id Connect Button.

  14. View the logs and see the refresh token again.
    55 - see token again

Expected behavior

I expect the refresh token to be available every time the user logs in.

Platform

(Please complete the following information)

  • Device: Desktop
  • OS: macOS
  • Browser + version Chrome 119.0.6045.159
  • Database PostgresSQL with image.

Community guidelines

All issues filed in this repository must abide by the FusionAuth community guidelines.

Additional context

N/A

@robotdan
Copy link
Member

robotdan commented Dec 8, 2023

The current design is that we take whatever the IdP returns and store it. So that means this is working how I expect.

We could optionally keep the previous value of the current login response doesn't return a refresh token.

The potential issue here is that we would just have to guess that the reason the IdP doesn't return a refresh token is because it thinks the prior one is still valid (assuming that is why Google is not retuning it on the second login - because the current session is still active).

Maybe this is a safe assumption? It just means we may hold onto old tokens unknowingly.

@jschatz1
Copy link

jschatz1 commented Dec 8, 2023

@robotdan @mark-robustelli I am confused. As a user of FusionAuth, I supposed to call Google to get the access token using the refresh token that is initially returned? I know that's how OAuth works but I was under the impression that fusionauth was handling much of the heavy lifting.
It does not say this in the docs that this is a refresh token.

@jschatz1
Copy link

jschatz1 commented Dec 8, 2023

To be clear all I need is the access token so I can call Google API's and I need that to be refreshed somehow. The token that comes back from retrieveUserLinksByUserId the typescript sdk is some times blank. This is my problem. @robotdan is right that we wouldn't expect the refresh token every time. I just need access to that access token so I can call Google APIs.

@mooreds
Copy link
Collaborator

mooreds commented Dec 8, 2023

@jschatz1 From https://fusionauth.io/docs/apis/identity-providers/openid-connect

FusionAuth will also store the refresh_token returned from the external OpenID Connect provider, if such a token is provided, in the identityProviderLink object, in the identityProviderLink.token field. This object is accessible using the Link API.

It varies based on the identity provider, but is documented in the API.

We should continue the support questions on the forum post, because this issue is for the bug that you uncovered (thank you!), not for support.

@mooreds
Copy link
Collaborator

mooreds commented Dec 8, 2023

@robotdan I agree that this is "working as designed" but it seems to me that nulling out an existing refresh token is not exactly behavior that the user will expect or desire. I think it is reasonable to think of the token field as remaining present. I think there are two options:

  • document that the refresh token may be lost (on a provider by provider basis, depending if they send back the refresh token for subsequent logins)
  • if the refresh token is not present, don't update the value.

the latter feels more in keeping with the documentation:

FusionAuth will also store the refresh_token returned from the external OpenID Connect provider, if such a token is provided, in the identityProviderLink object

Since the refresh token is not provided in the second login above, as Mark's screenshots show, we shouldn't update it. Basically, we should test if we get back a refresh token.

@jschatz1
Copy link

jschatz1 commented Dec 8, 2023

Honestly @mooreds if it was clearer that the token is a refresh token I might expect it to disappear. In many flows a refresh token is only provided once.

The API for the Link API does not re mention that this is a refresh token and instead it says it is an opaque token.

@mooreds
Copy link
Collaborator

mooreds commented Dec 8, 2023

Thanks for the feedback @jschatz1 . I'll take a look at the documentation and see if it can be made clearer.

@Noblebrown
Copy link

Pinging to see if there has been any further movement on this issue. Has anything been prioritized or investigated further, or is just a matter of updating the docs for clarity?

@mooreds
Copy link
Collaborator

mooreds commented Jan 19, 2024

@Noblebrown at this point, this is not in plan. The documentation may be clarified, but I don't expect any changes to the OIDC behavior.

@mooreds mooreds added the documentation An issue or clarification on documentation label Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation An issue or clarification on documentation
Projects
None yet
Development

No branches or pull requests

5 participants