loginListener method
void
loginListener(
- Uri l
)
Implementation
void loginListener(Uri l) async {
var qp = l.queryParameters;
if (qp["code"] == null) {
await closeInAppWebView();
Navigator.of(context).pop();
return;
}
// we got a code, fetch the matching auth info
var auth = await widget.api.req("OAuth2:token",
method: "POST",
skipDecode: true,
body: <String, String?>{
"client_id": widget.api.appId,
"grant_type": "authorization_code",
"redirect_uri": widget.redirectUri,
"code": qp["code"],
});
await widget.api.storeToken(auth);
await widget.api.user.fetchLogin();
if (widget.api.user.isLoggedIn()) {
print("closing view");
await closeInAppWebView();
print("close complete");
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed("/home");
} else {
await closeInAppWebView();
Navigator.of(context).pop();
}
}