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

Unhandled Exception: Platform #2

Open
Miles-Ahead-Digital opened this issue Nov 29, 2020 · 0 comments
Open

Unhandled Exception: Platform #2

Miles-Ahead-Digital opened this issue Nov 29, 2020 · 0 comments

Comments

@Miles-Ahead-Digital
Copy link

Miles-Ahead-Digital commented Nov 29, 2020

Hi,
if I login to a client a second time. I get this stacktrace at await launch(url, forceWebView: true); - but the logon still works.
I'm testing on iOS.

[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: PlatformException(Error, Error while launching https://keycloak.miles-ahead.cloud:8443/auth/realms/flutter/protocol/openid-connect/auth?response_type=code&scope=openid+&client_id=flutter&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2F&state=OX4JNHvT2vHs6ZWsCxC39AVHcex3WBQ5SGR6bxfDB2CA9MzW39&code_challenge_method=S256&code_challenge=ChNV82Y-d4nt8QqdIL8t8Gb5X0ZxgBb43ZnkF-DL-fE, null, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)
<asynchronous suspension>
#2      launch (package:url_launcher/url_launcher.dart:95:23)
<asynchronous suspension>
#3      OpenIdStore.signIn.<anonymous closure> (package:openid_client_master/src/blocs.dart:141:9)
<asynchronous suspension>
Future<UserInfo> signIn(Map<String, dynamic> clientInfo) async {
    print(" signIn started");
    var uri = Uri.parse(clientInfo["issuer"]);
    var issuer = await Issuer.discover(uri);
    var client = new Client(
      issuer,
      clientInfo["client_id"],
    );
    print(' signIn   $clientInfo["redirect_uri"]');
    var authenticator = new Authenticator(client,
        scopes: clientInfo["scopes"].split(","),
  //      redirectUri: clientInfo["redirect_uri"] == null
  //          ? null
  //          : Uri.parse(clientInfo["redirect_uri"]),
        port: 4000, urlLancher: (url) async {
      if (await canLaunch(url)) {
        await launch(url, forceWebView: true);
      } else {
        throw 'Could not launch $url';
      }
    });

How can we improve the code to avoid this error (better then just ignoring it with an empty try catch surrounding)?

Best regards
Stefan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant