authenticate method
Launches authorizationUrl and returns the callback URL it lands on.
Implementation
Future<Uri> authenticate({
required String authorizationUrl,
required Uri redirectUri,
bool preferEphemeral = false,
}) async {
final String callbackUrl;
try {
callbackUrl = await FlutterWebAuth2.authenticate(
url: authorizationUrl,
callbackUrlScheme: redirectUri.scheme,
options: FlutterWebAuth2Options(
// Required when the callback is an HTTPS URL: the platform matches
// the incoming link against these rather than against a scheme.
httpsHost: redirectUri.host,
httpsPath: redirectUri.path,
preferEphemeral: preferEphemeral,
),
);
} on PlatformException catch (err) {
if (err.code == 'CANCELED') {
throw SsoCancelledException();
}
rethrow;
}
final callbackUri = Uri.parse(callbackUrl);
_assertMatchesRedirectUri(callbackUri, redirectUri);
return callbackUri;
}