webAuth method
Handle OAuth2 session creation.
Implementation
@override
Future webAuth(Uri url, {String? callbackUrlScheme}) {
return FlutterWebAuth2.authenticate(
url: url.toString(),
callbackUrlScheme: callbackUrlScheme != null && _customSchemeAllowed
? callbackUrlScheme
: "appwrite-callback-" + config['project']!,
options: const FlutterWebAuth2Options(
intentFlags: ephemeralIntentFlags,
),
).then((value) async {
Uri url = Uri.parse(value);
final key = url.queryParameters['key'];
final secret = url.queryParameters['secret'];
if (key == null || secret == null) {
throw AppwriteException(
"Invalid OAuth2 Response. Key and Secret not available.", 500);
}
Cookie cookie = Cookie(key, secret);
cookie.domain = Uri.parse(_endPoint).host;
cookie.httpOnly = true;
cookie.path = '/';
List<Cookie> cookies = [cookie];
await init();
_cookieJar.saveFromResponse(Uri.parse(_endPoint), cookies);
});
}