Skip to content

[google_sign_in_ios] restorePreviousSignIn can throw PlatformException due to invalid grant #184134

@felangel

Description

@felangel

Steps to reproduce

google_sign_in_ios v6.3.0

  1. Sign in using GoogleSignIn.instance.authorizationClient.authorizeServer
  2. Sign out by calling disconnect
  3. Wait for a while (not sure exactly how long it takes for a token to expire)
  4. Attempt to repeat step 1.

Expected results

I would expect the authorization flow to proceed as normal.

Actual results

An uncaught exception is thrown:
PlatformException(org.openid.appauth.oauth_token: -10, invalid_grant: Token has been expired or revoked.)

Triggered from: await _api.restorePreviousSignIn();

Full PlatformException:

PlatformException(
  org.openid.appauth.oauth_token: -10, invalid_grant: Token has been expired or revoked.,
  {
    OIDOAuthErrorResponseErrorKey: {
      error: invalid_grant,
      error_description: Token has been expired or revoked.
    },
    NSLocalizedDescription: invalid_grant: Token has been expired or revoked.,
    NSUnderlyingError: {
      code: 400, domain: org.openid.appauth.remote-http,
      localizedDescription: {
        "error": "invalid_grant",
        "error_description": "Token has been expired or revoked."
      },
      userInfo: {
        NSLocalizedDescription: {
          "error": "invalid_grant",
          "error_description": "Token has been expired or revoked."
        }
      }
    }
  },
  null,
)

Code sample

Code sample
Future<void> performServerAuth() async {
  await GoogleSignIn.instance.authorizationClient.authorizeServer(scopes: ['email']);
}

Future<void> disconnect() => GoogleSignIn.instance.disconnect();

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs

N/A

Flutter Doctor output

Doctor output
flutter doctor --verbose
[✓] Flutter (Channel stable, 3.41.5, on macOS 26.3.1 25D2128 darwin-arm64, locale en-US) [445ms]
    • Flutter version 3.41.5 on channel stable at /Users/felangel/Development/github.com/flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2c9eb20739 (8 days ago), 2026-03-17 16:14:01 -0700
    • Engine revision 052f31d115
    • Dart version 3.11.3
    • DevTools version 2.54.2
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [2.6s]
    • Android SDK at /Users/felangel/Library/Android/sdk
    • Emulator version 36.3.10.0 (build_id 14472402) (CL:N/A)
    • Platform android-36, build-tools 36.1.0
    • ANDROID_HOME = /Users/felangel/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.8+-14196175-b1038.72)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.1.1) [979ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17B100
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [6ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (3 available) [9.3s]
    • iPhone SE (3rd generation) (mobile) • F7DA8E7E-AB50-4B85-B309-ACFA2D17FC68 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-26-1 (simulator)
    • macOS (desktop)                     • macos                                • darwin-arm64   • macOS 26.3.1 25D2128 darwin-arm64
    • Chrome (web)                        • chrome                               • web-javascript • Google Chrome 146.0.7680.154    

[✓] Network resources [147ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions