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

[firebase_auth_web] expirationTime returned from IdTokenResult on web is wrong #1875

Closed
rich-j opened this issue Jan 24, 2020 · 4 comments · Fixed by #3357
Closed

[firebase_auth_web] expirationTime returned from IdTokenResult on web is wrong #1875

rich-j opened this issue Jan 24, 2020 · 4 comments · Fixed by #3357
Labels
platform: ios Issues / PRs which are specifically for iOS. platform: web Issues / PRs which are specifically for web. plugin: auth type: bug Something isn't working

Comments

@rich-j
Copy link

rich-j commented Jan 24, 2020

On the web, the expirationTime value from an IdTokenResult is wrong. The token is obtained from fbUser.getIdToken(). Printing the value with debugPrint("Token expiration ${idTokenResult.expirationTime}"); on the web gives a date 50,000 years in the future:

Token expiration 52034-12-26 04:16:40.000

the same code on iOS it prints:

Token expiration 2020-01-24 14:50:50.000

using firebase_auth: 0.15.3+1 which brings in firebase_auth_web 0.1.1+4

Flutter (Channel beta, v1.13.6, on Mac OS X 10.15.2 19C57, locale en-US)
@rich-j rich-j added the type: bug Something isn't working label Jan 24, 2020
@Ehesp
Copy link
Member

Ehesp commented Aug 25, 2020

This should be fixed in the latest update. Thanks.

@Ehesp Ehesp closed this as completed Aug 25, 2020
@rich-j
Copy link
Author

rich-j commented Aug 25, 2020

@Ehesp No this is NOT FIXED!! It's even worse now since it doesn't even work on iOS.

      firebaseUser.getIdTokenResult().then((idTokenResult) {
        print("Token expiration ${idTokenResult.expirationTime}");
        return idTokenResult.token;
      });

On web Token expiration 1969-12-31 18:00:00.000 and on iOS Token expiration 1970-01-19 05:59:51.187. If it matters, we are using secondary Firebase auth sessions.

Replace the above print... with print("Token ${idTokenResult}"); (i.e. use the IdTokenResult .toString method) and you get these (with redactions) - iOS:

Token IdTokenResult(authTime: 1970-01-19 05:59:47.587, claims: {iat: 1598387587, 
firebase: {identities: {email: [rtest@ft.com]}, sign_in_provider: password}, email_verified: true,
sub: <xxx>, aud: <xxx>, auth_time: 1598387587, user_id: <xxx>, exp: 1598391187, email: rtest@ft.com,
iss: https://securetoken.google.com/<xxx>}, expirationTime: 1970-01-19 05:59:51.187,
issuedAtTime: 1970-01-19 05:59:47.587, signInProvider: password, token: <xxx>

and web:

NoSuchMethodError: invalid member on null: 'abs'
dart-sdk/lib/core/date_time.dart 390:38                                           _withValue
packages/firebase_auth_platform_interface/src/id_token_result.dart 26:18          get authTime
packages/firebase_auth_platform_interface/src/id_token_result.dart 53:39          toString
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 710:40  str
packages/goalery_app/src/environment/app_firebase_auth_session.dart 56:39         <fn>
dart-sdk/lib/async/zone.dart 1450:54                                              runUnary
dart-sdk/lib/async/future_impl.dart 143:18                                        handleValue
dart-sdk/lib/async/future_impl.dart 696:44                                        handleValueCallback
dart-sdk/lib/async/future_impl.dart 725:32                                        _propagateToListeners
dart-sdk/lib/async/future_impl.dart 529:5                                         [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 567:7                                         callback
dart-sdk/lib/async/schedule_microtask.dart 41:11                                  _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 50:5                                   _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15               <fn>

Yes, the web throws an exception on the .toString method.

  firebase_auth:
    version: "0.18.0+1"
  firebase_auth_platform_interface:
    version: "2.0.1"
  firebase_auth_web:
    version: "0.3.0+1"

@Ehesp Ehesp reopened this Aug 26, 2020
@Salakar Salakar added platform: ios Issues / PRs which are specifically for iOS. platform: web Issues / PRs which are specifically for web. plugin: auth labels Aug 26, 2020
@rich-j
Copy link
Author

rich-j commented Aug 26, 2020

@Ehesp FYI, we currently aren't setup for testing against Android since most fixes correct both mobile (iOS and Android) platforms. I see that fix 47eb554 corrects an incorrect conversion in iOS specific code. You may want to check the Android side too.

Thanks for fixing this (although I haven't yet tested it since it's not yet published...)

@Ehesp
Copy link
Member

Ehesp commented Aug 26, 2020

Yep Android is working 👍

@firebase firebase locked and limited conversation to collaborators Sep 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: ios Issues / PRs which are specifically for iOS. platform: web Issues / PRs which are specifically for web. plugin: auth type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants