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


C# Live.LiveAuthClient类代码示例

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


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

示例1: TailoredAuthClient

        /// <summary>
        /// Creates a new TailoredAuthClient class.
        /// </summary>
        /// <param name="authClient">The LiveAuthClient instance.</param>
        public TailoredAuthClient(LiveAuthClient authClient)
        {
            Debug.Assert(authClient != null, "authClient cannot be null.");

            this.authClient = authClient;
            this.authenticator = new OnlineIdAuthenticator();
        }
开发者ID:d20021,项目名称:LiveSDK-for-Windows,代码行数:11,代码来源:TailoredAuthClient.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: GetUserLogged

        private async Task<dynamic> GetUserLogged() 
        {
            var liveIdClient = new LiveAuthClient();
            Task<LiveLoginResult> tskLoginResult = liveIdClient.LoginAsync(new string[] { "wl.signin" });
            tskLoginResult.Wait();

            switch (tskLoginResult.Result.Status)
            {
                case LiveConnectSessionStatus.Connected:
                    try
                    {
                        LiveConnectClient client = new LiveConnectClient(tskLoginResult.Result.Session);
                        LiveOperationResult liveOperationResult = await client.GetAsync("me");

                        dynamic operationResult = liveOperationResult.Result;
                        return operationResult;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format("ERRO, {0}", ex.Message), ex);
                    }
                case LiveConnectSessionStatus.NotConnected:
                    break;
            }

            return null;
        }
开发者ID:aboimpinto,项目名称:GOT.Prolegis,代码行数:27,代码来源:ProlegisViewModelBase.cs

示例4: InitializePage

        private async void InitializePage()
        {
            try
            {
                this.authClient = new LiveAuthClient();
                LiveLoginResult loginResult = await this.authClient.InitializeAsync(scopes);
                if (loginResult.Status == LiveConnectSessionStatus.Connected)
                {
                    if (this.authClient.CanLogout)
                    {
                        this.btnLogin.Content = "Sign Out";
                    }
                    else
                    {
                        this.btnLogin.Visibility = Visibility.Collapsed;
                    }

                    this.liveClient = new LiveConnectClient(loginResult.Session);
                }
            }
            catch (LiveAuthException)
            {
                // TODO: Display the exception
            }
        }
开发者ID:harishdotnarayanan,项目名称:LiveSDK-for-Windows,代码行数:25,代码来源:MainPage.xaml.cs

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: LiveAuthClientCore

        /// <summary>
        /// Initializes an new instance of the LiveAuthClientCore class.
        /// </summary>
        public LiveAuthClientCore(
            string clientId,
            IDictionary<int, string> clientSecretMap, 
            IRefreshTokenHandler refreshTokenHandler,
            LiveAuthClient authClient)
        {
            Debug.Assert(!string.IsNullOrEmpty(clientId));
            Debug.Assert(clientSecretMap != null && clientSecretMap.Count > 0);
            Debug.Assert(authClient != null);

            this.clientId = clientId;
            this.clientSecrets = clientSecretMap;
            this.refreshTokenHandler = refreshTokenHandler;
            this.publicAuthClient = authClient;

            // Get latest version
            int largestIndex = clientSecretMap.Keys.First();
            if (clientSecretMap.Count > 1)
            {
                foreach (int index in clientSecretMap.Keys)
                {
                    if (index > largestIndex)
                    {
                        largestIndex = index;
                    }
                }
            }

            this.clientSecret = clientSecretMap[largestIndex];
        }
开发者ID:d20021,项目名称:LiveSDK-for-Windows,代码行数:33,代码来源:LiveAuthClientCore.cs

示例10: MyTestInitialize

 public void MyTestInitialize() 
 {
     this.authClient = new LiveAuthClient(TestAuthClient.ClientId);
     this.authClient.AuthClient = new TestAuthClient(this.authClient);
     this.authClient.AuthClient.CloseSession();
     WebRequestFactory.Current = new TestWebRequestFactory();
 }
开发者ID:namy14,项目名称:LiveSDK-for-Windows,代码行数:7,代码来源:TestCases.cs

示例11: 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

示例12: MainViewModel

        public MainViewModel(IPopupService popupService, SynchronizationContext synchonizationContext)
        {
            var client = new MobileServiceClient(
                _mobileServiceUrl,
                _mobileServiceKey);

            _liveAuthClient = new LiveAuthClient(_mobileServiceUrl);
            
            // Apply a ServiceFilter to the mobile client to help with our busy indication
            _mobileServiceClient = client.WithFilter(new DotoServiceFilter(
                busy =>
                {
                    IsBusy = busy;
                }));
            _popupService = popupService;
            _synchronizationContext = synchonizationContext;
            _invitesTable = _mobileServiceClient.GetTable<Invite>();
            _itemsTable = _mobileServiceClient.GetTable<Item>();
            _profilesTable = _mobileServiceClient.GetTable<Profile>();
            _listMembersTable = _mobileServiceClient.GetTable<ListMembership>();
            _devicesTable = _mobileServiceClient.GetTable<Device>();
            _settingsTable = _mobileServiceClient.GetTable<Setting>();

            SetupCommands();

            LoadSettings();
        }
开发者ID:TroyBolton,项目名称:azure-mobile-services,代码行数:27,代码来源:MainViewModel.cs

示例13: 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

示例14: 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

示例15: 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


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