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


C# LiveAuthClient.InitializeAsync方法代码示例

本文整理汇总了C#中Microsoft.Live.LiveAuthClient.InitializeAsync方法的典型用法代码示例。如果您正苦于以下问题:C# LiveAuthClient.InitializeAsync方法的具体用法?C# LiveAuthClient.InitializeAsync怎么用?C# LiveAuthClient.InitializeAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Live.LiveAuthClient的用法示例。


在下文中一共展示了LiveAuthClient.InitializeAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AuthenticateSilent

        /// <summary>
        /// Versucht Login, ohne einen entsprechenden Dialog zu zu zeigen.
        /// </summary>
        /// <returns>Ein MobileServiceUser, der awaited werden kann oder null bei Misserfolg.</returns>
        internal static async Task<MobileServiceUser> AuthenticateSilent(MobileServiceClient mobileService)
        {
            LiveAuthClient liveAuthClient = new LiveAuthClient(APIKeys.LiveClientId);
            session = (await liveAuthClient.InitializeAsync()).Session;
            return await mobileService.LoginWithMicrosoftAccountAsync(session.AuthenticationToken);

        }
开发者ID:JulianMH,项目名称:DoIt,代码行数:11,代码来源:LiveAuthenticator.cs

示例2: SignOutClick

        private async void SignOutClick(object sender, RoutedEventArgs e)
        {
            try
            {
                // Initialize access to the Live Connect SDK.
                LiveAuthClient LCAuth = new LiveAuthClient();
                LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
                // Sign the user out, if he or she is connected;
                //  if not connected, skip this and just update the UI
                if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
                {
                    LCAuth.Logout();
                }

                // At this point, the user should be disconnected and signed out, so
                //  update the UI.
                this.userName.Text = "You're not signed in.";

                // Show sign-in button.
                signInBtn.Visibility = Windows.UI.Xaml.Visibility.Visible;
                signOutBtn.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            catch (LiveConnectException x)
            {
                // Handle exception.
                this.userName.Text = x.Message.ToString();
                throw new NotImplementedException();
            }
        }
开发者ID:violabazanye,项目名称:BudgetWise,代码行数:29,代码来源:Account.xaml.cs

示例3: SetNameField

		private async Task SetNameField(Boolean login)
		{
			// If login == false, just update the name field. 
			await App.updateUserName(this.UserNameTextBlock, login);

			// Test to see if the user can sign out.
			Boolean userCanSignOut = true;

			var LCAuth = new LiveAuthClient();
			LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();

			if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
			{
				userCanSignOut = LCAuth.CanLogout;
			}

			var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

			if (String.IsNullOrEmpty(UserNameTextBlock.Text) 
				|| UserNameTextBlock.Text.Equals(loader.GetString("MicrosoftAccount/Text")))
			{
				// Show sign-in button.
				SignInButton.Visibility = Visibility.Visible;
				SignOutButton.Visibility = Visibility.Collapsed;
			}
			else
			{
				// Show sign-out button if they can sign out.
				SignOutButton.Visibility = userCanSignOut ? Visibility.Visible : Visibility.Collapsed;
				SignInButton.Visibility = Visibility.Collapsed;
			}
		}
开发者ID:vapps,项目名称:Modern_LiveBoard,代码行数:32,代码来源:AccountSettingsFlyout.xaml.cs

示例4: ensureConnection

 private async Task<LiveConnectClient> ensureConnection()
 {
     if (connection != null)
     {
         return connection;
     }
     // Initialize access to the Live Connect SDK.
     LiveAuthClient LCAuth = new LiveAuthClient("https://chivalry.azure-mobile.net/");
     LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
     // Sign in to the user's Microsoft account with the required scope.
     //    
     //  This call will display the Microsoft account sign-in screen if the user 
     //  is not already signed in to their Microsoft account through Windows 8.
     // 
     //  This call will also display the consent dialog, if the user has 
     //  has not already given consent to this app to access the data described 
     //  by the scope.
     // 
     LiveLoginResult loginResult = await LCAuth.LoginAsync(new string[] { "wl.basic", "wl.emails" });
     if (loginResult.Status == LiveConnectSessionStatus.Connected)
     {
         // Create a client session to get the profile data.
         connection = new LiveConnectClient(LCAuth.Session);
         mobileServiceUser = await App.MobileService.LoginAsync(loginResult.Session.AuthenticationToken);
         return connection;
     }
     if (LoginFailed != null)
     {
         LoginFailed(this, null);
     }
     return null;
 }
开发者ID:NickHeiner,项目名称:chivalry,代码行数:32,代码来源:Auth.cs

示例5: SignOutClick

        private async void SignOutClick(object sender, RoutedEventArgs e)
        {
            try
            {
                // Initialize access to the Live Connect SDK.
                LiveAuthClient LCAuth = new LiveAuthClient();
                LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
                // Sign the user out, if he or she is connected;
                //  if not connected, skip this and just update the UI
                if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
                {
                    
                    LCAuth.Logout();
                }

                // At this point, the user should be disconnected and signed out, so
                //  update the UI.
                this.userName.Text = "You're not signed in.";
                Connection.User = null;
                // Show sign-in button.
                signInBtn.Visibility = Windows.UI.Xaml.Visibility.Visible;
                signOutBtn.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                new MessageDialog("The app is exiting since you are no longer logged in.").ShowAsync();
                App.Current.Exit();
            }
            catch (LiveConnectException x)
            {
                // Handle exception.
            }
        }
开发者ID:Zainabalhaidary,项目名称:Clinic,代码行数:30,代码来源:Account.xaml.cs

示例6: SignOutButton_OnClick

		private async void SignOutButton_OnClick(object sender, RoutedEventArgs e)
		{
			try
			{
				// Initialize access to the Live Connect SDK.
				LiveAuthClient LCAuth = new LiveAuthClient();
				LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
				// Sign the user out, if he or she is connected;
				//  if not connected, skip this and just update the UI
				if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
				{
					LCAuth.Logout();
				}

				// At this point, the user should be disconnected and signed out, so
				//  update the UI.
				var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
				this.UserNameTextBlock.Text = loader.GetString("MicrosoftAccount/Text");

				// Show sign-in button.
				SignInButton.Visibility = Visibility.Visible;
				SignOutButton.Visibility = Visibility.Collapsed;
			}
			catch (LiveConnectException x)
			{
				// Handle exception.
			}
		}
开发者ID:vapps,项目名称:Modern_LiveBoard,代码行数:28,代码来源:AccountSettingsFlyout.xaml.cs

示例7: SetNameField

        private async Task SetNameField(Boolean login)
        {
          // await App.updateUserName(this.userName, login);
            this.userName.Text = Connection.UserName;
            Boolean userCanSignOut = true;

            LiveAuthClient LCAuth = new LiveAuthClient();
            LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();

            if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
            {
                userCanSignOut = LCAuth.CanLogout;
            }

            if (this.userName.Text.Equals("You're not signed in."))
            {
                // Show sign-in button.
                signInBtn.Visibility = Windows.UI.Xaml.Visibility.Visible;
                signOutBtn.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            else
            {
                // Show sign-out button if they can sign out.
                signOutBtn.Visibility = (userCanSignOut ? Windows.UI.Xaml.Visibility.Visible : Windows.UI.Xaml.Visibility.Collapsed);
                signInBtn.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
        }
开发者ID:Zainabalhaidary,项目名称:Clinic,代码行数:27,代码来源:Account.xaml.cs

示例8: LoginAsync

        public async Task<bool> LoginAsync(bool isSilent = true)
        {
            bool result = false;
            LastError = null;
            RestoreData = null;

            IsInProgress = true;

            try
            {
                var authClient = new LiveAuthClient();
                LiveLoginResult res = isSilent ? await authClient.InitializeAsync(scopes) : await authClient.LoginAsync(scopes);
                Session = res.Status == LiveConnectSessionStatus.Connected ? res.Session : null;

                result = true;
            }
            catch (LiveAuthException ex)
            {
                LastError = ex.Message;
            }

            IsInProgress = false;

            return result;
            //CheckPendingBackgroundOperations();
        }
开发者ID:KonstantinKolesnik,项目名称:EcosHub,代码行数:26,代码来源:LiveManager.cs

示例9: login_Client

 //인스턴스 생성용 method
 private async void login_Client()
 {
     try
     {
         //Client 생성
         authClient = new LiveAuthClient();
         //초기화
         result = await authClient.InitializeAsync();
         //로그인
         loginResult = await authClient.LoginAsync(scope);
         //로그인 할 떄 cancel을 누르면 뒤로 돌아가기
     }
     catch (NullReferenceException ex)
     {
         //로그인 할 때 cancel을 누르면 nullreferenceException 발생
         //뒤로가기
         ex.Message.ToString();
         messagePrint(false);
         if (Frame.CanGoBack)
         {
             Frame.GoBack();
         }
     }
     catch (Exception ex)
     {
         //기타 Exception을 위한 catch
         ex.Message.ToString();
         messagePrint(false);
         if(Frame.CanGoBack)
         {
             Frame.GoBack();
         }
     }
 }
开发者ID:sviom,项目名称:MoneyNote,代码行数:35,代码来源:BackupControl.xaml.cs

示例10: TestLiveSDKLogin

        /// <summary>
        /// Tests logging into MobileService with Live SDK token. App needs to be assosciated with a WindowsStoreApp
        /// </summary>
        private async Task TestLiveSDKLogin()
        {
            try
            {
                LiveAuthClient liveAuthClient = new LiveAuthClient(GetClient().MobileAppUri.ToString());
                LiveLoginResult result = await liveAuthClient.InitializeAsync(new string[] { "wl.basic", "wl.offline_access", "wl.signin" });
                if (result.Status != LiveConnectSessionStatus.Connected)
                {
                    result = await liveAuthClient.LoginAsync(new string[] { "wl.basic", "wl.offline_access", "wl.signin" });
                }
                if (result.Status == LiveConnectSessionStatus.Connected)
                {
                    LiveConnectSession session = result.Session;
                    LiveConnectClient client = new LiveConnectClient(result.Session);
                    LiveOperationResult meResult = await client.GetAsync("me");
                    MobileServiceUser loginResult = await GetClient().LoginWithMicrosoftAccountAsync(result.Session.AuthenticationToken);

                    Log(string.Format("{0} is now logged into MobileService with userId - {1}", meResult.Result["first_name"], loginResult.UserId));
                }
            }
            catch (Exception exception)
            {
                Log(string.Format("ExceptionType: {0} Message: {1} StackTrace: {2}",
                                                exception.GetType().ToString(),
                                                exception.Message,
                                                exception.StackTrace));
                Assert.Fail("Log in with Live SDK failed");
            }
        }
开发者ID:jwallra,项目名称:azure-mobile-apps-net-client,代码行数:32,代码来源:ClientSDKLoginTests.cs

示例11: DoLogin

 public async void DoLogin(string clientId)
 {
     var scopes = new List<string>();
     scopes.Add("wl.calendars");
     scopes.Add("http://outlook.office.com/Calendars.ReadWrite");
     var sdk = new LiveAuthClient(clientId);
     var result = await sdk.InitializeAsync(scopes);
     var url = sdk.GetLoginUrl(scopes);
     var token = sdk.Session.AuthenticationToken;
 }
开发者ID:Ahrimaan,项目名称:ChaosCalendarSync,代码行数:10,代码来源:LiveAccess.cs

示例12: Activate

 public async Task Activate()
 {
     var session = _cache.SkydriveSession;
     if (session == null)
     {
         var authClient = new LiveAuthClient(ApiKeys.SkyDriveClientId);
         var x = await authClient.InitializeAsync();
         session = x.Session;
     }
     _liveClient = new LiveConnectClient(session);
 }
开发者ID:TheAngryByrd,项目名称:MetroPass,代码行数:11,代码来源:SkydriveClient.cs

示例13: GetSession

        public async Task<LiveConnectSession> GetSession()
        {
            _client = new LiveAuthClient(_clientId, _tokenHandler);

            var existingToken = await _tokenHandler.RetrieveRefreshTokenAsync();
            if (existingToken != null)
            {
                var loginResult = await _client.InitializeAsync();
                return loginResult.Session;
            }
            return await LoginAsync();
        }
开发者ID:skendrot,项目名称:CloudBackup,代码行数:12,代码来源:Authenticator.cs

示例14: OnActivate

        protected async override Task OnActivate()
        {
            if (authClient == null)
            {
                authClient = new LiveAuthClient(ApiKeys.SkyDriveClientId);

                IEnumerable<string> scopes = ParseScopeString(Scopes);

                try
                {
                    Task<LiveLoginResult> result = authClient.InitializeAsync(scopes);
                    LiveLoginResult = await result;                   
                }
                catch (Exception exception)
                {
                    //this.RaiseSessionChangedEvent(new LiveConnectSessionChangedEventArgs(exception));
                }
            }
        }
开发者ID:TheAngryByrd,项目名称:MetroPass,代码行数:19,代码来源:SkydriveAccessViewModel.cs

示例15: authenticate2

        // Normal Auth
        private async Task<MobileServiceUser> authenticate2(bool singleSignOn)
        {
            LiveAuthClient liveIdClient = new LiveAuthClient("https://debtor.azure-mobile.net/");
            var reqs = new[] { "wl.signin", "wl.basic", "wl.offline_access" };

            LiveLoginResult init = await liveIdClient.InitializeAsync(reqs);
            if (init.Status != LiveConnectSessionStatus.Connected)
            {
                try
                {
                    await App.MobileService
                        .LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount, singleSignOn);
                }
                catch (InvalidOperationException)
                {
                }
            }

            return App.MobileService.CurrentUser;
        }
开发者ID:pinthecloud,项目名称:debtor,代码行数:21,代码来源:MainPage.xaml.cs


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