flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [firebase_auth] getIdTokenResult returns null values in IdTokenResult on Windows

Open danielgorka opened this issue 2 years ago • 10 comments

Bug report

Describe the bug When calling User.getIdTokenResult on Windows I've always got null values in IdTokenResult.authTime, IdTokenResult.claims.

Steps to reproduce

Steps to reproduce the behavior:

  1. Start Flutter app on Windows
  2. Sign in using signInWithEmailAndPassword
  3. Call getIdTokenResult
  4. Returned IdTokenResult has null values except token (claims, authTime etc.)

Expected behavior

Non null values in IdTokenResult.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.13.6, on Microsoft Windows [Version 10.0.22621.2428], locale pl-PL)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.4.4)
[√] Android Studio (version 2022.3)
[√] VS Code (version 1.83.1)
[√] Connected device (5 available)
[√] Network resources

• No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 3.1.3
Flutter SDK 3.13.6
firebase_example 1.0.0+1

dependencies:
- cupertino_icons 1.0.6
- firebase_auth 4.11.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 2.19.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math web sky_engine]

dev dependencies:
- flutter_lints 2.0.3 [lints]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math async boolean_selector characters collection material_color_utilities meta source_span stream_channel string_scanner term_glyph web]

transitive dependencies:
- _flutterfire_internals 1.3.9 [collection firebase_core firebase_core_platform_interface flutter meta]
- async 2.11.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- characters 1.3.0
- clock 1.1.1
- collection 1.17.2
- fake_async 1.3.1 [clock collection]
- firebase_auth_platform_interface 7.0.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 5.8.4 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta]
- firebase_core_platform_interface 5.0.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.8.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math web]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- js 0.6.7 [meta]
- lints 2.1.1
- matcher 0.12.16 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.5.0 [collection]
- meta 1.9.1
- path 1.8.3
- plugin_platform_interface 2.1.6 [meta]
- sky_engine 0.0.99
- source_span 1.10.0 [collection path term_glyph]
- stack_trace 1.11.0 [path]
- stream_channel 2.1.1 [async]
- string_scanner 1.2.0 [source_span]
- term_glyph 1.2.1
- test_api 0.6.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.3.2 [collection]
- vector_math 2.1.4
- web 0.1.4-beta

danielgorka avatar Oct 24 '23 12:10 danielgorka

Thanks for the report @danielgorka I currently don't have windows machine to verify this, but are you running it on desktop or on mobile using windows machine ?

darshankawar avatar Oct 25 '23 10:10 darshankawar

I'm running on desktop. On mobile everything works fine.

danielgorka avatar Oct 25 '23 10:10 danielgorka

Thanks for the update. My colleague was able to replicate this on his Windows machine wherein it gave below results:

flutter: token info: null

        print('token info: ${token?.authTime}');
        print('token info: ${token?.claims}');
        print('token info: ${token?.expirationTime}');
        print('token info: ${token?.issuedAtTime}');

darshankawar avatar Oct 26 '23 11:10 darshankawar

/cc @Lyokone

darshankawar avatar Oct 26 '23 11:10 darshankawar

Hi @danielgorka, this is a missing feature from the native C++ SDK. I'll report that to the internal team.

Lyokone avatar Oct 26 '23 12:10 Lyokone

Thank you for your quick attention to this. Looking forward to the update.

danielgorka avatar Oct 26 '23 13:10 danielgorka

+1 for this issue. As AppCheck and Callable Cloud Functions are not fully supported on all plattforms yet, I built a cloud function which accepts an authToken in the request, but this doesn't work out on Windows because of this issue. So I would also look forward to a fix 👍 Thank you.

perret123 avatar Dec 17 '23 11:12 perret123

Can't remember where i saw this but as a temporary fix until this is patched you can decode the token using https://pub.dev/packages/jwt_decoder and extract the claims

claimsMap = JwtDecoder.decode(
          (await getCurrentUser().getIdTokenResult()).toString());

jlundlumination avatar Jan 12 '24 03:01 jlundlumination

https://github.com/firebase/flutterfire/issues/11949#issuecomment-1829984711

Opened an issue on the C++ repository for support: firebase/firebase-cpp-sdk#1494

TarekkMA avatar Apr 23 '24 07:04 TarekkMA