From 48bbf6a4dbd4ea23be5dadafcd8c7c6f4843d533 Mon Sep 17 00:00:00 2001 From: harrowmykel Date: Tue, 18 Oct 2022 17:53:51 +0200 Subject: [PATCH 01/16] =?UTF-8?q?=F0=9F=8C=B9=20Add=20troubleshooting=20do?= =?UTF-8?q?cumentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/README.md b/README.md index 8c362a6..ed8d613 100644 --- a/README.md +++ b/README.md @@ -113,3 +113,119 @@ close the window. Redirection URL passed to the authentication service must be the same as the URL on which the application is running (schema, host, port if necessary) and the path must point to created HTML file, `/auth.html` in this case. The `callbackUrlScheme` parameter of the `authenticate()` method does not take into account, so it is possible to use a schema for native platforms in the code. For the Sign in with Apple in web_message response mode, postMessage from https://appleid.apple.com is also captured, and the authorization object is returned as a URL fragment encoded as a query string (for compatibility with other providers). + +## Troubleshooting + +When you use this package for the first time, there are some problems you may have. These are some of the common solutions + +### Troubleshooting `callbackUrlScheme` + +- `callbackUrlScheme` must be a valid schema string or else this wont work. +- A valid RFC 3986 URL scheme must consist of "a letter and followed by any combination of letters, digits, plus ("+"), period ("."), or hyphen ("-")." +- scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) +- This means you can not use underscore "_", space " " or uppercase "ABCDEF...". You can not also start with a number. See [RFC3986#page-17](https://www.rfc-editor.org/rfc/rfc3986#page-17) +- examples of VALID `callbackUrlScheme` are `callback-scheme`, `another.scheme`, `examplescheme` +- examples of INVALID `callbackUrlScheme` are `callback_scheme`,`1another.scheme`, `exampleScheme` + +### Troubleshooting Flutter App + +- You have to tell the `FlutterWebAuth.authenticate` function what your `callbackUrlScheme` is. +- Example if your `callbackUrlScheme` is `valid-callback-scheme`, your dart code will look like + + ```dart + import 'package:flutter_web_auth/flutter_web_auth.dart'; + + // Present the dialog to the user + final result = await FlutterWebAuth.authenticate(url: "https://my-custom-app.com/connect", callbackUrlScheme: "valid-callback-scheme"); + ``` + +### Troubleshooting Android + +- You are required to update your `AndroidManifest.xml` to include the `com.linusu.flutter_web_auth.CallbackActivity` activity something like + + ```xml + + + + + + + + + + + + + + + + ``` + +- Example of valid `AndroidManifest.xml` with VALID `callbackUrlScheme`. in the example below `valid-callback-scheme` is our `callbackUrlScheme` + + ```xml + + + + + + + + + + + + + + + ``` + +### Troubleshooting OAuth redirects + +- Your OAuth Provider must redirect to the valid `callbackUrlScheme` + `://`. This mean if your `callbackUrlScheme` is `validscheme`, your OAuth Provider must redirect to `validscheme://` +- Example with `php` + ```php + Go Back to App + ``` + +### Troubleshooting passing data to app + +- You can pass data back to your app by adding GET query parameters. This means by adding name=value type of data after your `callbackUrlScheme` + `://` + `?` +- example to pass `access-token` to your app a valid url for that could be + + ```text + my-callback-schema://?access-token=jdu9292s + ``` + +- You can pass multipe data by concatenating with `&` + + ```text + my-callback-schema://?data1=value1&data2=value2 + ``` + +- example to pass `access-token` and `user_id` to your app a valid url for that could be + + ```text + my-callback-schema://?access-token=jdu9292s&user_id=23 + ``` + +- You can get the data in your app by using `Uri.parse(result).queryParameters` + + ```dart + // Present the dialog to the user + final result = await FlutterWebAuth.authenticate(url: "https://my-custom-app.com/connect", callbackUrlScheme: "valid-callback-scheme"); + // Extract token from resulting url + String accessToken = Uri.parse(result).queryParameters['access-token']; + String userId = Uri.parse(result).queryParameters['user_id']; + ``` From b900c0a31398e96708f2a46d43fd3be69340c023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 1 Nov 2022 09:15:29 +0100 Subject: [PATCH 02/16] =?UTF-8?q?=F0=9F=8C=B9=20Add=20info=20about=20keybo?= =?UTF-8?q?ard=20not=20showing=20to=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ed8d613..bd1409c 100644 --- a/README.md +++ b/README.md @@ -229,3 +229,7 @@ When you use this package for the first time, there are some problems you may ha String accessToken = Uri.parse(result).queryParameters['access-token']; String userId = Uri.parse(result).queryParameters['user_id']; ``` + +### Cannot open keyboard on iOS + +This seems to be a bug in `ASWebAuthenticationSession`, and no work around have been found. Please see [issue #120](https://github.com/LinusU/flutter_web_auth/issues/120) for more info. From 7711753c67ab05d1f774b1bce8457e13c8714f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 1 Nov 2022 09:22:32 +0100 Subject: [PATCH 03/16] =?UTF-8?q?=F0=9F=8C=B9=20Add=20android:exported=20v?= =?UTF-8?q?alue=20to=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #109 --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bd1409c..974125c 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ In order to capture the callback url, the following `activity` needs to be added - + @@ -148,7 +148,7 @@ When you use this package for the first time, there are some problems you may ha - + @@ -167,7 +167,7 @@ When you use this package for the first time, there are some problems you may ha - + @@ -180,6 +180,13 @@ When you use this package for the first time, there are some problems you may ha ``` +- If you are targeting S+ (version 31 and above) you need to provide an explicit value for `android:exported`. If you followed earlier installation instructions this was not included. Make sure that you add `android:exported="true"` to the `com.linusu.flutter_web_auth.CallbackActivity` activity in your `AndroidManifest.xml` file. + + ```diff + - + + + ``` + ### Troubleshooting OAuth redirects - Your OAuth Provider must redirect to the valid `callbackUrlScheme` + `://`. This mean if your `callbackUrlScheme` is `validscheme`, your OAuth Provider must redirect to `validscheme://` From fabd0ddbdcd5dd1d796015c8cc6adec3136ac50e Mon Sep 17 00:00:00 2001 From: Humza Tareen Date: Tue, 1 Nov 2022 13:51:09 +0500 Subject: [PATCH 04/16] =?UTF-8?q?=F0=9F=90=9B=20Remove=20null=20aware=20op?= =?UTF-8?q?erators=20from=20not=20null=20widgets=20(#132)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WidgetsBinding is never null --- lib/flutter_web_auth.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/flutter_web_auth.dart b/lib/flutter_web_auth.dart index a57099e..8f9bd6d 100644 --- a/lib/flutter_web_auth.dart +++ b/lib/flutter_web_auth.dart @@ -30,8 +30,8 @@ class FlutterWebAuth { /// [callbackUrlScheme] should be a string specifying the scheme of the url that the page will redirect to upon successful authentication. /// [preferEphemeral] if this is specified as `true`, an ephemeral web browser session will be used where possible (`FLAG_ACTIVITY_NO_HISTORY` on Android, `prefersEphemeralWebBrowserSession` on iOS/macOS) static Future authenticate({required String url, required String callbackUrlScheme, bool? preferEphemeral}) async { - WidgetsBinding.instance?.removeObserver(_resumedObserver); // safety measure so we never add this observer twice - WidgetsBinding.instance?.addObserver(_resumedObserver); + WidgetsBinding.instance.removeObserver(_resumedObserver); // safety measure so we never add this observer twice + WidgetsBinding.instance.addObserver(_resumedObserver); return await _channel.invokeMethod('authenticate', { 'url': url, 'callbackUrlScheme': callbackUrlScheme, @@ -44,6 +44,6 @@ class FlutterWebAuth { /// terminate all `authenticate` calls with an error. static Future _cleanUpDanglingCalls() async { await _channel.invokeMethod('cleanUpDanglingCalls'); - WidgetsBinding.instance?.removeObserver(_resumedObserver); + WidgetsBinding.instance.removeObserver(_resumedObserver); } } From 3f0e6cb3b6bb6eac551f5d65427e1b9fe7997553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 1 Nov 2022 10:01:22 +0100 Subject: [PATCH 05/16] =?UTF-8?q?=F0=9F=8C=B9=20Add=20macOS=20Chrome=20iss?= =?UTF-8?q?ue=20to=20troubleshooting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 974125c..dce30d2 100644 --- a/README.md +++ b/README.md @@ -240,3 +240,7 @@ When you use this package for the first time, there are some problems you may ha ### Cannot open keyboard on iOS This seems to be a bug in `ASWebAuthenticationSession`, and no work around have been found. Please see [issue #120](https://github.com/LinusU/flutter_web_auth/issues/120) for more info. + +### Error on macOS if Chrome is default browser + +This seems to be a bug in `ASWebAuthenticationSession`, and no work around have been found. Please see [issue #136](https://github.com/LinusU/flutter_web_auth/issues/136) for more info. From 32d42b59aaed00b6fffe1ea26269779094fdf270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 1 Nov 2022 10:12:03 +0100 Subject: [PATCH 06/16] =?UTF-8?q?=F0=9F=8C=B9=20Add=20note=20about=20multi?= =?UTF-8?q?ple=20Google=20scopes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index dce30d2..1375601 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ final response = await http.post('https://www.googleapis.com/oauth2/v4/token', b final accessToken = jsonDecode(response.body)['access_token'] as String; ``` +**Note:** To use multiple scopes with Google, you need to encode them as a single string, separated by spaces. For example, `scope: 'email https://www.googleapis.com/auth/userinfo.profile'`. Here is [a list of all supported scopes](https://developers.google.com/identity/protocols/oauth2/scopes). + ## Setup Setup works as for any Flutter plugin, expect the Android and Web caveats outlined below: From be07a5876721a1a4794a243fcb400c47a24196b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 1 Nov 2022 10:20:02 +0100 Subject: [PATCH 07/16] =?UTF-8?q?=F0=9F=8E=89=20Add=20preferEphemeral=20su?= =?UTF-8?q?pport=20on=20macOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #111 --- macos/Classes/FlutterWebAuthPlugin.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/macos/Classes/FlutterWebAuthPlugin.swift b/macos/Classes/FlutterWebAuthPlugin.swift index feed6ac..addc07e 100644 --- a/macos/Classes/FlutterWebAuthPlugin.swift +++ b/macos/Classes/FlutterWebAuthPlugin.swift @@ -14,6 +14,7 @@ public class FlutterWebAuthPlugin: NSObject, FlutterPlugin { if call.method == "authenticate" { let url = URL(string: (call.arguments as! Dictionary)["url"] as! String)! let callbackURLScheme = (call.arguments as! Dictionary)["callbackUrlScheme"] as! String + let preferEphemeral = (call.arguments as! Dictionary)["preferEphemeral"] as! Bool var keepMe: Any? = nil let completionHandler = { (url: URL?, err: Error?) in @@ -40,6 +41,7 @@ public class FlutterWebAuthPlugin: NSObject, FlutterPlugin { } session.presentationContextProvider = provider + session.prefersEphemeralWebBrowserSession = preferEphemeral session.start() keepMe = session From 83fec043631578dde277acaba675b126a240580c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 1 Nov 2022 10:47:47 +0100 Subject: [PATCH 08/16] =?UTF-8?q?=F0=9F=8C=B9=20Fix=20tests=20under=20newe?= =?UTF-8?q?r=20Flutter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/flutter_web_auth_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/flutter_web_auth_test.dart b/test/flutter_web_auth_test.dart index dff580d..b740bc1 100644 --- a/test/flutter_web_auth_test.dart +++ b/test/flutter_web_auth_test.dart @@ -5,6 +5,8 @@ import 'package:flutter_web_auth/flutter_web_auth.dart'; void main() { const MethodChannel channel = MethodChannel('flutter_web_auth'); + TestWidgetsFlutterBinding.ensureInitialized(); + setUp(() { channel.setMockMethodCallHandler((MethodCall methodCall) async { expect(methodCall.method, 'authenticate'); From 4f89925117e31c9874e60c7bc379967233505284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 1 Nov 2022 10:48:09 +0100 Subject: [PATCH 09/16] =?UTF-8?q?=F0=9F=90=9B=20Throw=20a=20proper=20error?= =?UTF-8?q?=20on=20invalid=20callback=20scheme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/flutter_web_auth.dart | 6 ++++++ test/flutter_web_auth_test.dart | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/lib/flutter_web_auth.dart b/lib/flutter_web_auth.dart index 8f9bd6d..0f923b4 100644 --- a/lib/flutter_web_auth.dart +++ b/lib/flutter_web_auth.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:core'; import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart' show MethodChannel; @@ -18,6 +19,7 @@ class _OnAppLifecycleResumeObserver extends WidgetsBindingObserver { class FlutterWebAuth { static const MethodChannel _channel = const MethodChannel('flutter_web_auth'); + static RegExp _schemeRegExp = new RegExp(r"^[a-z][a-z0-9+.-]*$"); static final _OnAppLifecycleResumeObserver _resumedObserver = _OnAppLifecycleResumeObserver(() { _cleanUpDanglingCalls(); // unawaited @@ -30,6 +32,10 @@ class FlutterWebAuth { /// [callbackUrlScheme] should be a string specifying the scheme of the url that the page will redirect to upon successful authentication. /// [preferEphemeral] if this is specified as `true`, an ephemeral web browser session will be used where possible (`FLAG_ACTIVITY_NO_HISTORY` on Android, `prefersEphemeralWebBrowserSession` on iOS/macOS) static Future authenticate({required String url, required String callbackUrlScheme, bool? preferEphemeral}) async { + if (!_schemeRegExp.hasMatch(callbackUrlScheme)) { + throw ArgumentError.value(callbackUrlScheme, 'callbackUrlScheme', 'must be a valid URL scheme'); + } + WidgetsBinding.instance.removeObserver(_resumedObserver); // safety measure so we never add this observer twice WidgetsBinding.instance.addObserver(_resumedObserver); return await _channel.invokeMethod('authenticate', { diff --git a/test/flutter_web_auth_test.dart b/test/flutter_web_auth_test.dart index b740bc1..7207741 100644 --- a/test/flutter_web_auth_test.dart +++ b/test/flutter_web_auth_test.dart @@ -28,4 +28,11 @@ void main() { 'https://example.com/success', ); }); + + test('invalid scheme', () async { + await expectLater( + FlutterWebAuth.authenticate(url: 'https://example.com/login', callbackUrlScheme: 'foobar://test'), + throwsA(isA()), + ); + }); } From 707b3897e0a71c1d206aedf738c3beac7d63b647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 1 Nov 2022 11:17:01 +0100 Subject: [PATCH 10/16] =?UTF-8?q?=F0=9F=9A=A2=200.4.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 +++ example/ios/Podfile.lock | 10 ++-- example/ios/Runner.xcodeproj/project.pbxproj | 4 +- example/macos/Podfile.lock | 10 ++-- .../macos/Runner.xcodeproj/project.pbxproj | 4 +- example/pubspec.lock | 53 ++++++++----------- ios/flutter_web_auth.podspec | 2 +- macos/flutter_web_auth.podspec | 2 +- pubspec.lock | 51 ++++++++---------- pubspec.yaml | 2 +- 10 files changed, 69 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d67a15..abd9d8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.4.2 + +- πŸŽ‰ Add `preferEphemeral` support on macOS +- πŸ› Remove null aware operators from not null widgets (#132) +- πŸ› Throw a proper error on invalid callback scheme +- 🌹 Add troubleshooting documentation + ## 0.4.1 - πŸŽ‰ Add support for Flutter "add to app" (#106) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 7d6ed9c..3107fc0 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,6 +1,6 @@ PODS: - - Flutter (2.0.2) - - flutter_web_auth (0.4.1): + - Flutter (3.0.0) + - flutter_web_auth (0.4.2): - Flutter DEPENDENCIES: @@ -15,9 +15,9 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_web_auth/ios" SPEC CHECKSUMS: - Flutter: c48dd2c06f81cd2d28c2d5e68a129c76508452c2 - flutter_web_auth: 09a0abd245f1a07a3ff4dcf1247a048d89ee12a9 + Flutter: aef388869c2d2beecc8df50c818fa66e9c6eb1fb + flutter_web_auth: efb49f029fc0ccc6a9d693235b44b7cac8a41e8d PODFILE CHECKSUM: 58760ca3c5878cb71ae11bd6eeff33fd4ce06e4f -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.3 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 78a88ef..9384117 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -159,7 +159,7 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 4104B0A7B57AD235F933B342 /* [CP] Embed Pods Frameworks */, + 4E74E02405D36D3189F9914D /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -233,7 +233,7 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; }; - 4104B0A7B57AD235F933B342 /* [CP] Embed Pods Frameworks */ = { + 4E74E02405D36D3189F9914D /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index 8cce1fd..99055ec 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -1,7 +1,7 @@ PODS: - - flutter_web_auth (0.4.0): + - flutter_web_auth (0.4.2): - FlutterMacOS - - FlutterMacOS (2.0.0) + - FlutterMacOS (3.0.0) DEPENDENCIES: - flutter_web_auth (from `Flutter/ephemeral/.symlinks/plugins/flutter_web_auth/macos`) @@ -15,9 +15,9 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/flutter_web_auth/macos SPEC CHECKSUMS: - flutter_web_auth: 0432fb32dd550d65cc874aa596d952b2add0ad9d - FlutterMacOS: 2f1b456c4d9436c4d4d13919bd3be8ef03ba6322 + flutter_web_auth: 9f5a8310472792cef77f8f2227f39064be5d71ab + FlutterMacOS: 45e508c87e018a84368607c1203b4a59629ac279 PODFILE CHECKSUM: 882fce9150893cd66c23bbd28a572b3439b8ac6d -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.3 diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index c59dfa5..8c792c0 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -195,7 +195,7 @@ 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, - E28E59D45F4CECFD32065236 /* [CP] Embed Pods Frameworks */, + BE5B00560C8F70687635729D /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -324,7 +324,7 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - E28E59D45F4CECFD32065236 /* [CP] Embed Pods Frameworks */ = { + BE5B00560C8F70687635729D /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( diff --git a/example/pubspec.lock b/example/pubspec.lock index 2e6e402..e4029cd 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,28 +21,21 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +49,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -73,7 +66,7 @@ packages: path: ".." relative: true source: path - version: "0.4.1" + version: "0.4.2" flutter_web_plugins: dependency: transitive description: flutter @@ -85,28 +78,35 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -118,7 +118,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -139,35 +139,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.0.0" diff --git a/ios/flutter_web_auth.podspec b/ios/flutter_web_auth.podspec index 8e6c94a..f8f12e3 100644 --- a/ios/flutter_web_auth.podspec +++ b/ios/flutter_web_auth.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_web_auth' - s.version = '0.4.1' + s.version = '0.4.2' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A new flutter plugin project. diff --git a/macos/flutter_web_auth.podspec b/macos/flutter_web_auth.podspec index 4f7d17a..630fde4 100644 --- a/macos/flutter_web_auth.podspec +++ b/macos/flutter_web_auth.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_web_auth' - s.version = '0.4.1' + s.version = '0.4.2' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A new flutter plugin project. diff --git a/pubspec.lock b/pubspec.lock index 90d03b0..90f5437 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,35 +21,28 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -71,28 +64,35 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -104,7 +104,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -125,35 +125,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index bf0fc50..13573fb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_web_auth description: Flutter plugin for authenticating a user with a web service. -version: 0.4.1 +version: 0.4.2 homepage: https://github.com/LinusU/flutter_web_auth environment: From 2694d50a9b782aceea97f6197ccb778f793c4fdd Mon Sep 17 00:00:00 2001 From: Varun Kumar Madupu Date: Wed, 2 Nov 2022 21:33:53 +0530 Subject: [PATCH 11/16] =?UTF-8?q?=F0=9F=90=9B=20Revert=20accidental=20brea?= =?UTF-8?q?king=20change=20(#142)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous release accidentally broke compatibility with Flutter v2, but made it compatible with Flutter v3. This commit reverts that so that the 0.4.x release line stays compatible with Flutter v2. --- lib/flutter_web_auth.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/flutter_web_auth.dart b/lib/flutter_web_auth.dart index 0f923b4..7c289c2 100644 --- a/lib/flutter_web_auth.dart +++ b/lib/flutter_web_auth.dart @@ -36,8 +36,8 @@ class FlutterWebAuth { throw ArgumentError.value(callbackUrlScheme, 'callbackUrlScheme', 'must be a valid URL scheme'); } - WidgetsBinding.instance.removeObserver(_resumedObserver); // safety measure so we never add this observer twice - WidgetsBinding.instance.addObserver(_resumedObserver); + WidgetsBinding.instance?.removeObserver(_resumedObserver); // safety measure so we never add this observer twice + WidgetsBinding.instance?.addObserver(_resumedObserver); return await _channel.invokeMethod('authenticate', { 'url': url, 'callbackUrlScheme': callbackUrlScheme, @@ -50,6 +50,6 @@ class FlutterWebAuth { /// terminate all `authenticate` calls with an error. static Future _cleanUpDanglingCalls() async { await _channel.invokeMethod('cleanUpDanglingCalls'); - WidgetsBinding.instance.removeObserver(_resumedObserver); + WidgetsBinding.instance?.removeObserver(_resumedObserver); } } From 48775039d59f262a6d1284392e7989b76756b298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Wed, 2 Nov 2022 17:06:10 +0100 Subject: [PATCH 12/16] =?UTF-8?q?=F0=9F=9A=A2=200.4.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ example/ios/Podfile.lock | 4 ++-- example/macos/Podfile.lock | 4 ++-- ios/flutter_web_auth.podspec | 2 +- macos/flutter_web_auth.podspec | 2 +- pubspec.yaml | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abd9d8e..264079f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.3 + +- πŸ› Revert accidental breaking change (#142) + ## 0.4.2 - πŸŽ‰ Add `preferEphemeral` support on macOS diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 3107fc0..ad81787 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,6 +1,6 @@ PODS: - Flutter (3.0.0) - - flutter_web_auth (0.4.2): + - flutter_web_auth (0.4.3): - Flutter DEPENDENCIES: @@ -16,7 +16,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: aef388869c2d2beecc8df50c818fa66e9c6eb1fb - flutter_web_auth: efb49f029fc0ccc6a9d693235b44b7cac8a41e8d + flutter_web_auth: 71382897b8dc10ad94a2928cbb09ddf515749808 PODFILE CHECKSUM: 58760ca3c5878cb71ae11bd6eeff33fd4ce06e4f diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index 99055ec..e601e4c 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - flutter_web_auth (0.4.2): + - flutter_web_auth (0.4.3): - FlutterMacOS - FlutterMacOS (3.0.0) @@ -15,7 +15,7 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/flutter_web_auth/macos SPEC CHECKSUMS: - flutter_web_auth: 9f5a8310472792cef77f8f2227f39064be5d71ab + flutter_web_auth: 544a4ba14cdd7cbe4001e41dffd43e1cdf2831c6 FlutterMacOS: 45e508c87e018a84368607c1203b4a59629ac279 PODFILE CHECKSUM: 882fce9150893cd66c23bbd28a572b3439b8ac6d diff --git a/ios/flutter_web_auth.podspec b/ios/flutter_web_auth.podspec index f8f12e3..0df31b9 100644 --- a/ios/flutter_web_auth.podspec +++ b/ios/flutter_web_auth.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_web_auth' - s.version = '0.4.2' + s.version = '0.4.3' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A new flutter plugin project. diff --git a/macos/flutter_web_auth.podspec b/macos/flutter_web_auth.podspec index 630fde4..86b3964 100644 --- a/macos/flutter_web_auth.podspec +++ b/macos/flutter_web_auth.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_web_auth' - s.version = '0.4.2' + s.version = '0.4.3' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A new flutter plugin project. diff --git a/pubspec.yaml b/pubspec.yaml index 13573fb..08ea5f3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_web_auth description: Flutter plugin for authenticating a user with a web service. -version: 0.4.2 +version: 0.4.3 homepage: https://github.com/LinusU/flutter_web_auth environment: From 316aa6a1b05eb31b36dde26089358bbb896bcdbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Wed, 2 Nov 2022 17:15:04 +0100 Subject: [PATCH 13/16] =?UTF-8?q?=F0=9F=92=A5=20Upgrade=20to=20Flutter=20v?= =?UTF-8?q?ersion=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migration Guide: This release drops support for Flutter v2, and adds support for Flutter v3. Make sure to upgrade to Flutter v3 when upgrading to this version. --- example/pubspec.lock | 4 ++-- lib/flutter_web_auth.dart | 6 +++--- pubspec.lock | 2 +- pubspec.yaml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index e4029cd..9067296 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -66,7 +66,7 @@ packages: path: ".." relative: true source: path - version: "0.4.2" + version: "0.4.3" flutter_web_plugins: dependency: transitive description: flutter @@ -163,4 +163,4 @@ packages: version: "2.1.2" sdks: dart: ">=2.17.0-0 <3.0.0" - flutter: ">=2.0.0" + flutter: ">=3.0.0" diff --git a/lib/flutter_web_auth.dart b/lib/flutter_web_auth.dart index 7c289c2..0f923b4 100644 --- a/lib/flutter_web_auth.dart +++ b/lib/flutter_web_auth.dart @@ -36,8 +36,8 @@ class FlutterWebAuth { throw ArgumentError.value(callbackUrlScheme, 'callbackUrlScheme', 'must be a valid URL scheme'); } - WidgetsBinding.instance?.removeObserver(_resumedObserver); // safety measure so we never add this observer twice - WidgetsBinding.instance?.addObserver(_resumedObserver); + WidgetsBinding.instance.removeObserver(_resumedObserver); // safety measure so we never add this observer twice + WidgetsBinding.instance.addObserver(_resumedObserver); return await _channel.invokeMethod('authenticate', { 'url': url, 'callbackUrlScheme': callbackUrlScheme, @@ -50,6 +50,6 @@ class FlutterWebAuth { /// terminate all `authenticate` calls with an error. static Future _cleanUpDanglingCalls() async { await _channel.invokeMethod('cleanUpDanglingCalls'); - WidgetsBinding.instance?.removeObserver(_resumedObserver); + WidgetsBinding.instance.removeObserver(_resumedObserver); } } diff --git a/pubspec.lock b/pubspec.lock index 90f5437..d4b764c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -149,4 +149,4 @@ packages: version: "2.1.2" sdks: dart: ">=2.17.0-0 <3.0.0" - flutter: ">=2.0.0" + flutter: ">=3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 08ea5f3..05a359e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,8 +4,8 @@ version: 0.4.3 homepage: https://github.com/LinusU/flutter_web_auth environment: - sdk: ">=2.12.0 <3.0.0" - flutter: ">=2.0.0" + sdk: ">=2.17.0-0 <3.0.0" + flutter: ">=3.0.0" dependencies: flutter: From d9fe83fdd6af3b6d40fb2640265d15b3da3d960d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Wed, 2 Nov 2022 17:17:34 +0100 Subject: [PATCH 14/16] =?UTF-8?q?=F0=9F=9A=A2=200.5.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 ++++++++ example/ios/Podfile.lock | 4 ++-- example/macos/Podfile.lock | 4 ++-- example/pubspec.lock | 2 +- ios/flutter_web_auth.podspec | 2 +- macos/flutter_web_auth.podspec | 2 +- pubspec.yaml | 2 +- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 264079f..39e9067 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.5.0 + +- πŸ’₯ Upgrade to Flutter version 3 + + Migration guide: + + This release drops support for Flutter v2, and adds support for Flutter v3. Make sure to upgrade to Flutter v3 when upgrading to this version. + ## 0.4.3 - πŸ› Revert accidental breaking change (#142) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index ad81787..3f60895 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,6 +1,6 @@ PODS: - Flutter (3.0.0) - - flutter_web_auth (0.4.3): + - flutter_web_auth (0.5.0): - Flutter DEPENDENCIES: @@ -16,7 +16,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: aef388869c2d2beecc8df50c818fa66e9c6eb1fb - flutter_web_auth: 71382897b8dc10ad94a2928cbb09ddf515749808 + flutter_web_auth: c25208760459cec375a3c39f6a8759165ca0fa4d PODFILE CHECKSUM: 58760ca3c5878cb71ae11bd6eeff33fd4ce06e4f diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index e601e4c..871590f 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - flutter_web_auth (0.4.3): + - flutter_web_auth (0.5.0): - FlutterMacOS - FlutterMacOS (3.0.0) @@ -15,7 +15,7 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/flutter_web_auth/macos SPEC CHECKSUMS: - flutter_web_auth: 544a4ba14cdd7cbe4001e41dffd43e1cdf2831c6 + flutter_web_auth: f129850adcc025e7136109a53a00aac93ec62076 FlutterMacOS: 45e508c87e018a84368607c1203b4a59629ac279 PODFILE CHECKSUM: 882fce9150893cd66c23bbd28a572b3439b8ac6d diff --git a/example/pubspec.lock b/example/pubspec.lock index 9067296..67deacc 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -66,7 +66,7 @@ packages: path: ".." relative: true source: path - version: "0.4.3" + version: "0.5.0" flutter_web_plugins: dependency: transitive description: flutter diff --git a/ios/flutter_web_auth.podspec b/ios/flutter_web_auth.podspec index 0df31b9..eb4b6e7 100644 --- a/ios/flutter_web_auth.podspec +++ b/ios/flutter_web_auth.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_web_auth' - s.version = '0.4.3' + s.version = '0.5.0' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A new flutter plugin project. diff --git a/macos/flutter_web_auth.podspec b/macos/flutter_web_auth.podspec index 86b3964..daadd23 100644 --- a/macos/flutter_web_auth.podspec +++ b/macos/flutter_web_auth.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_web_auth' - s.version = '0.4.3' + s.version = '0.5.0' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A new flutter plugin project. diff --git a/pubspec.yaml b/pubspec.yaml index 05a359e..9b10339 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_web_auth description: Flutter plugin for authenticating a user with a web service. -version: 0.4.3 +version: 0.5.0 homepage: https://github.com/LinusU/flutter_web_auth environment: From 1a54e737846e158f79892bd60dbb30acf024505e Mon Sep 17 00:00:00 2001 From: Will May <4763133+Will5@users.noreply.github.com> Date: Thu, 17 Nov 2022 16:32:42 -0500 Subject: [PATCH 15/16] iOS Authentication works in 0.4.0, but not in 0.4.1 - AQUIRE_ROOT_VIEW_CONTROLLER_FAILED --- ios/Classes/SwiftFlutterWebAuthPlugin.swift | 33 ++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/ios/Classes/SwiftFlutterWebAuthPlugin.swift b/ios/Classes/SwiftFlutterWebAuthPlugin.swift index e334c20..9c70715 100644 --- a/ios/Classes/SwiftFlutterWebAuthPlugin.swift +++ b/ios/Classes/SwiftFlutterWebAuthPlugin.swift @@ -54,20 +54,33 @@ public class SwiftFlutterWebAuthPlugin: NSObject, FlutterPlugin { let session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme, completionHandler: completionHandler) if #available(iOS 13, *) { - guard var topController = UIApplication.shared.keyWindow?.rootViewController else { - result(FlutterError.aquireRootViewControllerFailed) + var rootViewController: UIViewController? = nil + + // FlutterViewController + if (rootViewController == nil) { + rootViewController = UIApplication.shared.delegate?.window??.rootViewController as? FlutterViewController + } + + // UIViewController + if (rootViewController == nil) { + rootViewController = UIApplication.shared.keyWindow?.rootViewController + } + + // ACQUIRE_ROOT_VIEW_CONTROLLER_FAILED + if (rootViewController == nil) { + result(FlutterError.acquireRootViewControllerFailed) return } - while let presentedViewController = topController.presentedViewController { - topController = presentedViewController + while let presentedViewController = rootViewController!.presentedViewController { + rootViewController = presentedViewController } - if let nav = topController as? UINavigationController { - topController = nav.visibleViewController ?? topController + if let nav = rootViewController as? UINavigationController { + rootViewController = nav.visibleViewController ?? rootViewController } - guard let contextProvider = topController as? ASWebAuthenticationPresentationContextProviding else { - result(FlutterError.aquireRootViewControllerFailed) + guard let contextProvider = rootViewController as? ASWebAuthenticationPresentationContextProviding else { + result(FlutterError.acquireRootViewControllerFailed) return } session.presentationContextProvider = contextProvider @@ -100,7 +113,7 @@ extension FlutterViewController: ASWebAuthenticationPresentationContextProviding } fileprivate extension FlutterError { - static var aquireRootViewControllerFailed: FlutterError { - return FlutterError(code: "AQUIRE_ROOT_VIEW_CONTROLLER_FAILED", message: "Failed to aquire root view controller" , details: nil) + static var acquireRootViewControllerFailed: FlutterError { + return FlutterError(code: "ACQUIRE_ROOT_VIEW_CONTROLLER_FAILED", message: "Failed to acquire root view controller" , details: nil) } } From 6afdfdc93c2ee93ea6e60e510912e573e6798c62 Mon Sep 17 00:00:00 2001 From: Arina Date: Thu, 15 Dec 2022 21:13:52 +0300 Subject: [PATCH 16/16] Fix HTTP POST call in example code (#148) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update README.md as breaking changes in http dart packet please consider to use * Update README.md Co-authored-by: Linus UnnebΓ€ck --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1375601..9628290 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,11 @@ final result = await FlutterWebAuth.authenticate(url: url.toString(), callbackUr // Extract code from resulting url final code = Uri.parse(result).queryParameters['code']; +// Construct an Uri to Google's oauth2 endpoint +final url = Uri.https('www.googleapis.com', 'oauth2/v4/token'); + // Use this code to get an access token -final response = await http.post('https://www.googleapis.com/oauth2/v4/token', body: { +final response = await http.post(url, body: { 'client_id': googleClientId, 'redirect_uri': '$callbackUrlScheme:/', 'grant_type': 'authorization_code',