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


C# MobileServiceAuthenticationProvider类代码示例

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


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


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