authenticate method

  1. @override
Future<String> authenticate({
  1. required Uri authorizationUrl,
  2. required FhirUri redirectUri,
})
override

Only method is to authenticate, this launches another window and redirects so you will need to remember to put a redirect.html file in your web folder

Implementation

@override
Future<String> authenticate({
  required Uri authorizationUrl,
  required FhirUri redirectUri,
}) async {
  final popupLogin = html.window.open(
      authorizationUrl.toString(),
      'oauth2_client::authenticateWindow',
      'menubar=no, status=no, scrollbars=no, menubar=no, width=1000, height=800');

  try {
    final messageEvt = await html.window.onMessage
        .firstWhere((evt) => evt.origin == redirectUri.value!.origin);

    popupLogin.close();

    return messageEvt.data;
  } catch (e, stack) {
    return 'Failed with Exception:$e\nHere is the Stack: $stack';
  }
}