auth0 / auth0-flutter

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

Failed to support LinkedIn login #432

Open fogfish opened 2 months ago

fogfish commented 2 months ago

Checklist

Description

Usage of LinkedIn login and flutter web fails with the following error:

Error: TypeError: null: type 'Null' is not a subtype of type 'String'
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3   throw_
dart-sdk/lib/_internal/js_shared/lib/rti.dart 1385:3                          _failedAsCheck
dart-sdk/lib/_internal/js_shared/lib/rti.dart 1363:3                          _generalAsCheckImplementation
dart-sdk/lib/_internal/js_shared/lib/js_util_patch.dart 81:5                  getProperty
packages/auth0_flutter/src/web/extensions/web_exception_extensions.dart 6:19  WebExceptionExtension.fromJsObject
packages/auth0_flutter/src/web/auth0_flutter_plugin_real.dart 128:49          credentials
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50            <fn>

The root cause is https://github.com/auth0/auth0-flutter/blob/main/auth0_flutter/lib/src/web/extensions/user_profile_extension.dart#L53

The lib expect locale claim to be String. However, LinkedIn return nested JSON Object:

"locale": {
    "country": "US",
    "language": "en"
  },

Reproduction

  1. Config LinkedIn OAuth app
  2. Config Auth0 to using this app
  3. Run auth0_flutter sample app with html renderer
  4. Login to LinkedIn

Additional context

No response

auth0_flutter version

1.6.0

Flutter version

Flutter 3.19.3 • channel stable

Platform

Web

Platform version(s)

No response