auth0 / auth0-flutter

Auth0 SDK for Flutter
https://pub.dev/documentation/auth0_flutter/latest/
Apache License 2.0
61 stars 41 forks source link

Fix access token expiry android #315

Closed poovamraj closed 12 months ago

poovamraj commented 1 year ago

πŸ“‹ Changes

This error is happening because in Java we were parsing the credentials result as Z which refers to timezone parsing in Java

But this was later changed to escape as shown below.

Screenshot 2023-10-12 at 13 38 20

This means we were initially parsing the timestamp as UTC at the dart layer when credentials were retrieved and to be same as that we had to set timezone while saving the credentials.

But after that we have removed parsing timezone by escaping the Z with quotes ''. But we haven't removed the timezone being set in save credentials handler. This caused the time to jump to the offset of UTC.

We have fixed this by removing the timezone in save credentials handler.

πŸ“Ž References

https://github.com/auth0/auth0-flutter/issues/286 https://github.com/auth0/auth0-flutter/pull/162 https://github.com/auth0/auth0-flutter/compare/v1.0.1...main

🎯 Testing

Existing unit test has been fixed to avoid this issue

Widcket commented 1 year ago

Wasn't the Z escaped in this PR: https://github.com/auth0/auth0-flutter/pull/238?

Widcket commented 1 year ago

In fact, we requested the escaped format:

Screenshot 2023-10-12 at 1 07 04 PM

Are we sure this change won't re-introduce this issue? https://github.com/auth0/auth0-flutter/issues/160

poovamraj commented 1 year ago

Yes, escaping it would be the right thing. But while we escaped the timezone "Z" which will parse the date to local time, we have forgotten to remove

format.timeZone = TimeZone.getTimeZone("UTC")

Also this would have caused issues for API login and other places since it was set only here and not in the other places where we format date

Widcket commented 1 year ago

It'd be great to have a single date formatter (or format string) in the entire Android native layer, to avoid these kinds of issues.

joymyr commented 12 months ago

This fixes the token refesh issue for me. Please merge it

codecov[bot] commented 12 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (0186ee5) 95.88% compared to head (4ece863) 95.79%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #315 +/- ## ========================================== - Coverage 95.88% 95.79% -0.09% ========================================== Files 75 76 +1 Lines 1117 1118 +1 Branches 281 281 ========================================== Hits 1071 1071 - Misses 45 46 +1 Partials 1 1 ``` | [Flag](https://app.codecov.io/gh/auth0/auth0-flutter/pull/315/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=auth0) | Coverage Ξ” | | |---|---|---| | [auth0_flutter](https://app.codecov.io/gh/auth0/auth0-flutter/pull/315/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=auth0) | `100.00% <ΓΈ> (ΓΈ)` | | | [auth0_flutter_ios](https://app.codecov.io/gh/auth0/auth0-flutter/pull/315/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=auth0) | `?` | | | [auth0_flutter_platform_interface](https://app.codecov.io/gh/auth0/auth0-flutter/pull/315/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=auth0) | `87.03% <ΓΈ> (ΓΈ)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=auth0#carryforward-flags-in-the-pull-request-comment) to find out more. [see 1 file with indirect coverage changes](https://app.codecov.io/gh/auth0/auth0-flutter/pull/315/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=auth0)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

aprzedecki commented 12 months ago

Great! Can we release it also on pub.dev ?

mng-prophero commented 11 months ago

Great! Can we release it also on pub.dev ?

We're needing this released as well as it's affecting our users

Widcket commented 11 months ago

πŸ‘‹πŸΌ I expect to cut a release by EOW.