authorize method
- {String? tokenResponseString}
override
Initiates the authorization process.
Discovers the OpenID Connect issuer configuration, creates a client, and launches the authorization process using the specified URL launcher.
Throws an error if the authorization URL cannot be launched.
Implementation
@override
Future<void> authorize({
String? tokenResponseString,
}) async {
final issuer = await Issuer.discover(Uri.parse('$_issuerUrl/v2.0'));
final client = Client(issuer, _clientId);
if (tokenResponseString == null) {
urlLauncher(String urlString) async {
var url = '$urlString$_query';
var uri = Uri.parse(url);
if (await canLaunchUrl(uri) || Platform.isAndroid) {
await launchUrl(uri, mode: _launchMode);
} else {
throw 'Could not launch $url';
}
}
Authenticator authenticator = Authenticator(
client,
scopes: _scopes,
port: _port,
urlLancher: urlLauncher,
);
credential = await authenticator.authorize();
} else {
credential = fromTokenResponseString(client, tokenResponseString);
}
}