我正在使用 Xamarin.Android 开发一个应用程序,并且我需要登录系统。因此我使用 Xamarin.Auth。我创建了一个 OAuth2Authenticator 但不工作 auth.completed 。fire auth.completed 如何成功?
public void LoginToSabis()
{
var auth = new OAuth2Authenticator(
clientId: "example_android",
scope: "read",
authorizeUrl: new Uri("example/authorize"),
redirectUrl: new Uri("ex/callback"));
auth.AllowCancel = true;
// If authorization succeeds or is canceled, .Completed will be fired. BUT WHEN SUCCEEDS NOT WORKING, WHEN CANCELED WORKING...
auth.Completed += async (s, ee) =>
{
if (!ee.IsAuthenticated)
{
var builder = new Android.Support.V7.App.AlertDialog.Builder(this);
builder.SetMessage("Not Authenticated");
builder.SetPositiveButton("Ok", (o, e) => { });
builder.Create().Show();
return;
}
AccountStore.Create(Application.Context).Save(ee.Account, "cg");
StartActivity(typeof(LoginRedirectActivity));
};
}