authenticate function
Implementation
Future<Credential?> authenticate(
Client client, {
List<String> scopes = const [],
Map<String, String>? queryParameters,
}) async {
// create a function to open a browser with an url
Future<bool> urlLauncher(String url) async {
var uri = Uri.parse(url);
if (await canLaunchUrl(uri) || UniversalPlatform.isAndroid) {
return await launchUrl(uri, webOnlyWindowName: '_self');
} else {
throw 'Could not launch $url';
}
}
// create an authenticator
var authenticator = io.Authenticator(client,
scopes: scopes, port: 4000, urlLancher: urlLauncher);
// starts the authentication
var c = await authenticator.authorize();
try {
closeInAppWebView();
} catch (_) {}
return c;
}