Skip to content

Refresh_token_expires_in not getting from google OAuth token api by passing ServerAuthCode. #565

Closed

Description

@anuragverse14

Describe the bug
I am getting a serverAuthCode which doesn't gives Refresh_token_expires_in from google Oauth token api call when user not checkmarked the ongoing access for google account.

To Reproduce
Steps to reproduce the behavior:

  1. Call GIDSignIn.sharedInstance.signIn(withPresenting: rootViewController, hint: email, additionalScopes: scopes)
  2. User get prompted for google sign inand then scopes list will be shown to the user.
  3. User will not select Ongoing access and select all required scopes, then click on continue.
  4. Code side we will get serverAuthCode and we will use google Oauth token api to get refresh token.
  5. We will get refresh token but not refresh_token_expires_in to know whether refresh token is long lived or not.

Expected behavior
As user has not selected ongoing access, we should be getting refresh_token_expires_in and it should be 15551999.

Environment

  • Device: iPhone 11
  • OS: 18.2.1
  • Browser: Internal browser(may be safari) launch by GIDSignIn

Additional context
Either you can expose refresh_token_expires_in from GIDSignIn response or can provide a serverAuthCode which helps in getting the same. I have tried with serverAuthCode got from android app and call google OAuth token api and that gives the refresh_token_expires_in.

Activity

  1. added
    bugSomething isn't working
    triageIssues that need to be triaged
    on Dec 2, 2025
  2. brnnmrls commented on Dec 26, 2025

    @brnnmrls
    Member

    Hey, thanks for your issue!

    I gave this a run on my end using our DaysUntilBirthday sample app, and received a refresh_token_expires_in value. This value is exposed under the additionalParameters field once we receive a token response here. The following is a screenshot of the refresh_token_expires_in value and its location on my end:
    Image

    Is this something you're looking for?

  3. anuragverse14 commented on Jan 17, 2026

    @anuragverse14
    Author

    I am looking for the same, but it is not accessible outside the library.
    One more thing i can't pass access_type=offline in GIDSignIn.sharedInstance.signIn(.....) function, so i can't get offline refresh token. So I need to call googleapi.com/oauth api along with serverAuthCode for getting a refresh token with offline access. Actually i need refersh_token_expires_in value in that api call response, but i never get there.

    Best way is to pass access_type=offline in GIDSignIn.sharedInstance.signIn(.....) call and expose refresh_token_expires_in outside the library(Public access). This way i can get refresh token and refresh_token_expires_in.

    Could you please update library functions with above requirement in next version?

  4. added
    enhancementNew feature or request
    questionFurther information is requested
    and removed
    bugSomething isn't working
    triageIssues that need to be triaged
    on Jan 23, 2026
  5. w-goog commented on Jan 23, 2026

    @w-goog
    Contributor

    The expiration date of the tokens is available on the client here. That being said, you'll ideally be calling the refreshTokensIfNeeded function on the user - https://developers.google.com/identity/sign-in/ios/backend-auth#send-the-id-token-to-your-server

    We'll follow up separately with regards to access_type=offline. Generally speaking, though, that bit should be happening on your backend, not the client.

  6. anuragverse14 commented on Jan 25, 2026

    @anuragverse14
    Author

    The expiration date which you are pointing out above is coming as empty/null for me, So it has no usage for me.
    If there is any other way to get offline refresh_token and refresh_token_expires_in, Please let me know the steps.

    Other possibility to get above data is to pass access_type=offline in GIDSignIn.sharedInstance.signIn(.....) call and expose refresh_token_expires_in outside the library(Public access). This way i can get refresh token and refresh_token_expires_in.

  7. added a commit that references this issue on Feb 4, 2026
    f5aa90b
  8. w-goog commented on Feb 5, 2026

    @w-goog
    Contributor

    Re: the expiration date - mea culpa! We did not add that when a handful of Google APIs added support for refresh token rotation. That's being added in the PR linked above, and we'll close this issue once it's complete.

    That being said, I don't know if it's going to solve your issue - what you are seeing is expected behaviour for ~most refresh tokens, which are long-lived. Your user has not selected ongoing access; so, when your attempt to authenticate with the access token fails, you'd then attempt to exchange the refresh token. If your refresh token has not expired, you'll get a new access token. If it has expired, you'll need the user to re-authenticate.

    Checking the refresh token expiration will save your app (and Google's server) a network roundtrip, but it's not going to give your app offline access - by leaving "Ongoing Access" unchecked, the user has indicated that they don't want your app to have offline access :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions