本文整理汇总了C#中OAuth2Authenticator.OnSucceeded方法的典型用法代码示例。如果您正苦于以下问题:C# OAuth2Authenticator.OnSucceeded方法的具体用法?C# OAuth2Authenticator.OnSucceeded怎么用?C# OAuth2Authenticator.OnSucceeded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuth2Authenticator
的用法示例。
在下文中一共展示了OAuth2Authenticator.OnSucceeded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoginToVk
void LoginToVk()
{
var auth = new OAuth2Authenticator (
clientId: VkSettings.AppID,
scope: "friends,video,audio",
//clientSecret: VkSettings.SecureKey,
authorizeUrl: new Uri ("https://oauth.vk.com/authorize"),
redirectUrl: new Uri ("https://oauth.vk.com/blank.html"));
auth.AllowCancel = true;
auth.Completed += (s, ee) => {
if (!ee.IsAuthenticated) {
return;
}
else
{
var token = ee.Account.Properties ["access_token"].ToString ();
var userId = ee.Account.Properties ["user_id"].ToString ();
var user = App.Container.Resolve<ISession> ().CurrentUser;
user.VkUserInfo = new VkUserInfo(token, userId);
auth.OnSucceeded (ee.Account);
user.Save ();
//this.DismissViewController (true, null);
page.Navigation.PopAsync ();
}
};
auth.Error += (sender, e) => {
var a = 4;
};
var nav = auth.GetUI () as UINavigationController;
controller = nav.TopViewController;
this.AddChildViewController (controller);
this.View.AddSubview (controller.View);
}
示例2: LoginToVk
private void LoginToVk()
{
var auth = new OAuth2Authenticator(
clientId: VkSettings.AppID,
scope: "friends,video,audio",
//clientSecret: VkSettings.SecureKey,
authorizeUrl: new Uri("https://oauth.vk.com/authorize"),
redirectUrl: new Uri("https://oauth.vk.com/blank.html")) {AllowCancel = true};
auth.Completed += (s, ee) => {
if (!ee.IsAuthenticated) {
#if DEBUG
Debug.WriteLine("Not authenticated! Try to relogin");
throw new AuthException("Not authenticated! In VkAuthController");
#endif
}
else
{
var token = ee.Account.Properties ["access_token"].ToString ();
var userId = ee.Account.Properties ["user_id"].ToString ();
var user = App.Container.Resolve<ISession> ().CurrentUser;
user.VkUserInfo = new VkUserInfo(token, userId);
auth.OnSucceeded (ee.Account);
user.Save ();
//this.DismissViewController (true, null);
page.Navigation.PopAsync ();
}
};
auth.Error += (sender, e) =>
{
throw e.Exception;
};
var nav = auth.GetUI () as UINavigationController;
Debug.Assert(nav != null, "nav != null");
controller = nav.TopViewController;
AddChildViewController (controller);
View.AddSubview (controller.View);
}