• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MobileServiceAuthenticationProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MobileServiceAuthenticationProvider的典型用法代码示例。如果您正苦于以下问题:C# MobileServiceAuthenticationProvider类的具体用法?C# MobileServiceAuthenticationProvider怎么用?C# MobileServiceAuthenticationProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MobileServiceAuthenticationProvider类属于命名空间,在下文中一共展示了MobileServiceAuthenticationProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Login

		private async Task Login(MobileServiceAuthenticationProvider provider)
		{
			var user = await _authenticationService.Login(provider);
			var userName = await GetIsOauthUserRegistered (user.UserId);
			await _databaseService.SaveCurrentUserAsync(new User { UserName = userName } );

			await _databaseService.DeleteAllScheduledConferencesAsync ();
			var conferenceDtos = await _remoteConferenceService.LoadScheduledConferencesAsync (userName);

			foreach (var conferenceDto in conferenceDtos) {
				var dto = conferenceDto;
				dto.IsAddedToSchedule = true;
				var conference = await TaskEx.Run (() => Mapper.Map<Conference> (dto));

				await _databaseService.SaveConferenceAsync (conference);

				foreach (var sessionDto in dto.Sessions)
				{
					SessionDto dto1 = sessionDto;
					var session = await TaskEx.Run(() => Mapper.Map<Session>(dto1));
					session.ConferenceId = conference.Id;
					await _databaseService.SaveSessionAsync(session);

					foreach (var speakerDto in sessionDto.Speakers)
					{
						SpeakerDto speakerDto1 = speakerDto;
						var speaker = await TaskEx.Run(() => Mapper.Map<Speaker>(speakerDto1));
						speaker.SessionId = session.Id;
						await _databaseService.SaveSpeakerAsync(speaker);
					}
				}
			}

			ShowViewModel<ConferencesTabViewModel> ();
		}
开发者ID:prca,项目名称:tekconf.mobile,代码行数:35,代码来源:LoginViewModel.cs


示例2: LoginAsync

        public async Task<MobileServiceUser> LoginAsync(MobileServiceClient client, MobileServiceAuthenticationProvider provider)
        {
            try
            {
                var window = UIKit.UIApplication.SharedApplication.KeyWindow;
                var root = window.RootViewController;
                if(root != null)
                {
                    var current = root;
                    while(current.PresentedViewController != null)
                    {
                        current = current.PresentedViewController;
                    }


                    Settings.LoginAttempts++;

                    var user = await client.LoginAsync(current, provider);

                    Settings.AuthToken = user?.MobileServiceAuthenticationToken ?? string.Empty;
                    Settings.UserId = user?.UserId ?? string.Empty;

                    return user;
                }
            }
            catch(Exception e)
            {
                e.Data["method"] = "LoginAsync";
                Xamarin.Insights.Report(e);
            }

            return null;
        }
开发者ID:RCWade,项目名称:app-coffeecups,代码行数:33,代码来源:Authentication.cs


示例3: Authenticate

        private async Task Authenticate(MobileServiceAuthenticationProvider provider)
        {
           

                try
                {
                    WAMSRepositoryService service = Mvx.Resolve<IRepositoryService>() as WAMSRepositoryService;
                    user = await service.MobileService
                        .LoginAsync(this, provider);


                }
                catch (InvalidOperationException e)
                {

                }


                var vm = ViewModel as AuthViewModel;

                if (user != null)
                {

                    vm.CreateUserCommand.Execute(user);
                }
                else
                {
                    vm.BackCommand.Execute(null);
                }
         
        }
开发者ID:aocsa,项目名称:CInca,代码行数:31,代码来源:AuthView.cs


示例4: loginAsync

		public async void loginAsync(MobileServiceAuthenticationProvider provider){
			while(! await DependencyService.Get<IAuthenticate> ().loginAsync (MobileServiceAuthenticationProvider.Twitter)){
				await DisplayAlert ("Login Fail", "Please try to login again", "OK");
			}
			await DisplayAlert ("Login", "Logged in successfully as: " +App.MobileService.CurrentUser.UserId, "OK");
			await Navigation.PushAsync (new Profile("twitter"));
		}
开发者ID:marignygrisgris,项目名称:QuickDev,代码行数:7,代码来源:Login.cs


示例5: TestRefreshUserAsync

 /// <summary>
 /// Tests the <see cref="MobileServiceClient.RefreshUserAsync"/> functionality on the platform.
 /// </summary>
 /// <param name="provider">
 /// The provider with which to login.
 /// </param>
 /// <returns>
 /// The UserId and MobileServiceAuthentication token obtained from logging in.
 /// </returns>
 public static async Task<string> TestRefreshUserAsync(MobileServiceAuthenticationProvider provider)
 {
     string result;
     switch (provider)
     {
         case MobileServiceAuthenticationProvider.MicrosoftAccount:
             result = await TestMicrosoftAccountRefreshUserAsync();
             break;
         case MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory:
             result = await TestAADRefreshUserAsync();
             break;
         case MobileServiceAuthenticationProvider.Google:
             result = await TestGoogleRefreshUserAsync();
             break;
         case MobileServiceAuthenticationProvider.Facebook:
             result = await TestFacebookRefreshUserAsync();
             break;
         case MobileServiceAuthenticationProvider.Twitter:
             result = await TestTwitterRefreshUserAsync();
             break;
         default:
             result = "MobileServiceAuthenticationProvider is not recognized.";
             break;
     }
     return result;
 }
开发者ID:Azure,项目名称:azure-mobile-apps-net-client,代码行数:35,代码来源:LoginTests.cs


示例6: Authenticate

        private async System.Threading.Tasks.Task Authenticate(MobileServiceAuthenticationProvider msap)
        {
            try
            {
                user = await App.MobileService.LoginAsync(msap);
            }
            catch
            {

            }
            
            //THIS NEEDS TO BE FIXED TO STORE THE USER'S CREDENTIALs.
            //while (user == null)
            //{
            //    string message;
            //    try
            //    {
            //        user = await App.MobileService.LoginAsync(msap);
            //        message =
            //            string.Format("You are now logged in - {0}", user.UserId);
            //    }
            //    catch (InvalidOperationException)
            //    {
            //        message = "You must log in. Login Required";
            //    }

            //    MessageBox.Show(message);
            //}
        }
开发者ID:jeffblankenburg,项目名称:FanaticApp,代码行数:29,代码来源:LogInScreen.xaml.cs


示例7: DoLoginAsync

        private async Task DoLoginAsync(MobileServiceAuthenticationProvider provider)
        {
            MobileServiceUser user;

            try
            {
                user = await DependencyService.Get<IMobileClient>().LoginAsync(provider);
                App.AuthenticatedUser = user;
                System.Diagnostics.Debug.WriteLine("Authenticated with user: " + user.UserId);

#if __DROID__
                Droid.GcmService.RegisterWithMobilePushNotifications();
#elif __IOS__
                iOS.AppDelegate.IsAfterLogin = true;
                await iOS.AppDelegate.RegisterWithMobilePushNotifications();
#elif __WP__
                ContosoMoments.WinPhone.App.AcquirePushChannel(App.MobileService);
#endif

                //Navigation.InsertPageBefore(new ImagesList(), this);
                Navigation.InsertPageBefore(new AlbumsListView(), this);
                await Navigation.PopAsync();
            }
            catch (InvalidOperationException ex)
            {
                if (ex.Message.Contains("Authentication was cancelled"))
                {
                    messageLabel.Text = "Authentication cancelled by the user";
                }
            }
            catch (Exception ex)
            {
                messageLabel.Text = "Authentication failed";
            }
        }
开发者ID:cephalin,项目名称:ContosoMoments,代码行数:35,代码来源:Login.xaml.cs


示例8: AuthenticateAsync

        /// <summary>
        /// Starts the authentication process.
        /// </summary>
        /// <param name="provider">The provider to authenticate with.</param>
        public async Task AuthenticateAsync(MobileServiceAuthenticationProvider provider)
        {
            try
            {
                var vault = new PasswordVault();

                // Login with the identity provider.
                var user = await AzureAppService.Current
                    .LoginAsync(provider);

                // Create and store the user credentials.
                var credential = new PasswordCredential(provider.ToString(),
                    user.UserId, user.MobileServiceAuthenticationToken);

                vault.Add(credential);
            }
            catch (InvalidOperationException invalidOperationException)
            {
                if (invalidOperationException.Message
                    .Contains("Authentication was cancelled by the user."))
                {
                    throw new AuthenticationCanceledException("Authentication canceled by user",
                        invalidOperationException);
                }

                throw new AuthenticationException("Authentication failed", invalidOperationException);
            }
            catch (Exception e)
            {
                throw new AuthenticationException("Authentication failed", e);
            }
        }
开发者ID:Microsoft,项目名称:Appsample-Photosharing,代码行数:36,代码来源:AuthenticationHandler.cs


示例9: Login

 private async void Login(MobileServiceAuthenticationProvider provider)
 {
     var client = new MobileServiceClient(this.uriEntry.Value, this.keyEntry.Value);
     var user = await client.LoginAsync(this, provider);
     var alert = new UIAlertView("Welcome", "Your userId is: " + user.UserId, null, "OK");
     alert.Show();
 }
开发者ID:RecursosOnline,项目名称:azure-mobile-services,代码行数:7,代码来源:LoginViewController.cs


示例10: LoginToken

 public LoginToken(MobileServiceUser user, MobileServiceAuthenticationProvider provider)
 {
     if (user != null && !string.IsNullOrWhiteSpace(user.MobileServiceAuthenticationToken))
     {
         User = user;
     }
     Provider = provider;
 }
开发者ID:rprouse,项目名称:IdeaTrackr-v1,代码行数:8,代码来源:LoginToken.cs


示例11: MobileServiceTokenAuthentication

        /// <summary>
        /// Instantiates a new instance of <see cref="MobileServiceTokenAuthentication"/>.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="provider">
        /// The authentication provider.
        /// </param>
        /// <param name="token">
        /// The token.
        /// </param>
        public MobileServiceTokenAuthentication(MobileServiceClient client, MobileServiceAuthenticationProvider provider, JObject token)
            :base(client, provider)
        {
            Debug.Assert(client != null, "client should not be null.");
            Debug.Assert(token != null, "token should not be null.");

            this.client = client;
            this.token = token;
        }
开发者ID:nberardi,项目名称:azure-mobile-services,代码行数:21,代码来源:MobileServiceTokenAuthentication.cs


示例12: LoginAsync

        /// <summary>
        /// Log a user into a Mobile Services application given a provider name and optional token object.
        /// </summary>
        /// <param name="provider" type="MobileServiceAuthenticationProvider">
        /// Authentication provider to use.
        /// </param>
        /// <param name="client">
        /// The <see cref="MobileServiceClient"/> to login with.
        /// </param>
        /// <param name="useSingleSignOn">
        /// Indicates that single sign-on should be used. Single sign-on requires that the
        /// application's Package SID be registered with the Windows Azure Mobile Service, but it
        /// provides a better experience as HTTP cookies are supported so that users do not have to
        /// login in everytime the application is launched.
        /// </param>
        /// <returns>
        /// Task that will complete when the user has finished authentication.
        /// </returns>
        public static Task<MobileServiceUser> LoginAsync(this IMobileServiceClient client, MobileServiceAuthenticationProvider provider, bool useSingleSignOn)
        {
            if(!useSingleSignOn)
            {
                return client.LoginAsync(provider);
            }

            MobileServiceSingleSignOnAuthentication auth = new MobileServiceSingleSignOnAuthentication(client, provider);
            return auth.LoginAsync();
        }
开发者ID:nberardi,项目名称:azure-mobile-services,代码行数:28,代码来源:SingleSignOnExtensions.cs


示例13: LoginAsync

        public Task<MobileServiceUser> LoginAsync(IMobileServiceClient client, MobileServiceAuthenticationProvider provider, IDictionary<string, string> parameters = null)
        {
            try
            {
                return client.LoginAsync(Forms.Context, provider, parameters);
            }
            catch { }

            return null;
        }
开发者ID:jamesmontemagno,项目名称:app-coffeecups,代码行数:10,代码来源:SocialAuthentication.cs


示例14: CreateLoginTest

 private static ZumoTest CreateLoginTest(MobileServiceAuthenticationProvider provider, bool useSingleSignOn)
 {
     string testName = string.Format("Login with {0}{1}", provider, useSingleSignOn ? " (using single sign-on)" : "");
     return new ZumoTest(testName, async delegate(ZumoTest test)
     {
         var client = ZumoTestGlobals.Instance.Client;
         var user = await client.LoginAsync(provider, useSingleSignOn);
         test.AddLog("Logged in as {0}", user.UserId);
         return true;
     });
 }
开发者ID:csff,项目名称:azure-mobile-services,代码行数:11,代码来源:ZumoLoginTests.cs


示例15: LoginAsync

 public async Task<MobileServiceUser> LoginAsync(MobileServiceAuthenticationProvider provider)
 {
     try
     {
         return await mobileService.LoginAsync(provider);
     }
     catch (InvalidOperationException)
     {
         return null;
     }
 }
开发者ID:nigel-sampson,项目名称:talks,代码行数:11,代码来源:AuthenticationService.cs


示例16: MobileServiceAuthentication

        /// <summary>
        /// Initializes a new instance of the <see cref="MobileServiceAuthentication"/> class.
        /// </summary>
        /// <param name="client">
        /// The <see cref="MobileServiceClient"/> associated with this 
        /// MobileServiceLogin instance.
        /// </param>
        /// <param name="provider">
        /// The <see cref="MobileServiceAuthenticationProvider"/> used to authenticate.
        /// </param>
        public MobileServiceAuthentication(IMobileServiceClient client, MobileServiceAuthenticationProvider provider)
        {
            Debug.Assert(client != null, "client should not be null.");

            this.Client = client;
            this.Provider = provider;

            string providerName = this.Provider.ToString().ToLower();

            this.StartUri = new Uri(this.Client.ApplicationUri, MobileServiceAuthentication.LoginAsyncUriFragment + "/" + providerName);
            this.EndUri = new Uri(this.Client.ApplicationUri, MobileServiceAuthentication.LoginAsyncDoneUriFragment);
        }
开发者ID:nberardi,项目名称:azure-mobile-services,代码行数:22,代码来源:MobileServiceAuthentication.cs


示例17: Login

 private async Task Login(MobileServiceAuthenticationProvider provider)
 {
     try
     {
         var user = await MobileService.LoginAsync(provider);
         AddToDebug("Logged in as {0}", user.UserId);
     }
     catch (Exception ex)
     {
         this.AddToDebug("Error: {0}", ex);
     }
 }
开发者ID:aeee98,项目名称:blogsamples,代码行数:12,代码来源:MainPage.xaml.cs


示例18: LoginAsync

        private async Task LoginAsync(MobileServiceAuthenticationProvider provider)
        {
            var user = await authentication.LoginAsync(provider);

            if (user == null)
            {

            }
            else
            {
                applicationNavigation.ToCurrentExpenses();
            }
        }
开发者ID:nigel-sampson,项目名称:talks,代码行数:13,代码来源:LoginViewModel.cs


示例19: loginAsync

		public async Task<bool> loginAsync (MobileServiceAuthenticationProvider provider){
			string message;
			try{
				await App.MobileService.LoginAsync (Forms.Context,provider);
				return true;
			}
			catch(InvalidOperationException){
				return false;
			}
			catch(Exception e){
				return false;
			}
		}
开发者ID:marignygrisgris,项目名称:QuickDev,代码行数:13,代码来源:AuthenticateAndroid.cs


示例20: loginAsync

		public async Task<bool> loginAsync (MobileServiceAuthenticationProvider provider){
			string message;
			try{
				var view = UIApplication.SharedApplication.KeyWindow.RootViewController;
				await App.MobileService.LoginAsync (view, provider);
				return true;
			}
			catch(InvalidOperationException){
				return false;
			}
			catch(Exception e){
				return false;
			}
		}
开发者ID:marignygrisgris,项目名称:QuickDev,代码行数:14,代码来源:AuthenticateIOS.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MobileServiceClient类代码示例发布时间:2022-05-24
下一篇:
C# Mobile类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap