auth0 / auth0-flutter

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

App crashes when using Apple Connection in Web sign in #314

Closed kipprice closed 11 months ago

kipprice commented 1 year ago

Checklist

Description

When trying to log in with Apple OAuth on flutter web, the credentials fail to parse, resulting in Flutter interpreting this as a failed authentication (even though according to the Auth0 logs, the auth was successful). The failure occurs when attempting to parse this line in user_profile_extension.dart:

isEmailVerified: claims[PublicClaims.emailVerified] as bool?,

When logging in with Apple, the value of email_verified is set to "true" (i.e., a boolean string, not a true boolean). I've tested with Google OAuth as well, which succeeds (and sends an actual boolean true in the email_verified field).

This appears to be from a similar root cause as issue #186, where Android could not cast a boolean string from the credentials from Apple to a true boolean. Similar to that issue, I have no problems on iOS using Apple credentials. I have not tested Android.

Reproduction

  1. Enable Apple authentication for a Auth0 Flutter Web application connected to the sample app
  2. Attempt to log in with an Apple account
  3. See that the login was successful in the Auth0 monitoring logs
  4. See that the flutter app remains on the login page
  5. See a crash in the dart / chrome console that looks like the following
    
    Uncaught (in promise) Error: Expected a value of type 'String', but got one of type 'Null'
    at Object.throw_ [as throw] (errors.dart:294:49)
    at Object.castError (errors.dart:127:3)
    at Object.cast [as as] (operations.dart:742:12)
    at String.as (core_patch.dart:674:17)
    at Object.getProperty (js_util_patch.dart:77:5)
    at Object.WebExceptionExtension$124fromJsObject [as WebExceptionExtension|fromJsObject] (web_exception_extensions.dart:6:19)
    at auth0_flutter_plugin_real.Auth0FlutterPlugin.new.credentials$ (auth0_flutter_plugin_real.dart:128:35)
    at credentials$.next (<anonymous>)
    at async_patch.dart:45:50
    at _RootZone.runUnary (zone.dart:1661:54)
    at _FutureListener.thenAwait.handleValue (future_impl.dart:156:18)
    at handleValueCallback (future_impl.dart:840:44)
    at _Future._propagateToListeners (future_impl.dart:869:13)
    at [_completeWithValue] (future_impl.dart:641:5)
    at async._AsyncCallbackEntry.new.callback (future_impl.dart:715:7)
    at Object._microtaskLoop (schedule_microtask.dart:40:11)
    at _startMicrotaskLoop (schedule_microtask.dart:49:5)
    at async_patch.dart:181:15


### Additional context

_No response_

### auth0_flutter version

1.2.1

### Flutter version

3.13.5

### Platform

Web

### Platform version(s)

_No response_
Widcket commented 1 year ago

Hi @kipprice, thanks for raising this. There's already a PR open for fixing this issue: https://github.com/auth0/auth0-flutter/pull/309, I just need to find some time to look into it.

Widcket commented 11 months ago

The fix is now out in v1.3.1.