当前位置: 首页>>代码示例>>C#>>正文


C# OAuth2Authenticator.OnSucceeded方法代码示例

本文整理汇总了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);
        }
开发者ID:Grawl,项目名称:hubbl,代码行数:34,代码来源:AuthController.cs

示例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);
        }
开发者ID:mesenev,项目名称:hubbl,代码行数:38,代码来源:VkAuthController.cs


注:本文中的OAuth2Authenticator.OnSucceeded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。