Пример #1
0
        /// <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);

        }
Пример #2
0
        /// <summary>
        /// Login mit einem entsprechenden Dialog.
        /// </summary>
        /// <returns>Ein MobileServiceUser, der awaited werden kann oder null bei Misserfolg.</returns>
        internal async static Task<MobileServiceUser> Authenticate(MobileServiceClient mobileService)
        {
            LiveAuthClient liveAuthClient = new LiveAuthClient(APIKeys.LiveClientId);
            var source = new TaskCompletionSource<MobileServiceUser>();

            liveAuthClient.Logout();

            var scopes = new string[] { "wl.basic", "wl.offline_access", "wl.signin" };
            App.Current.RootVisual.Visibility = System.Windows.Visibility.Collapsed;

            try
            {
                session = (await liveAuthClient.LoginAsync(scopes)).Session;
            }
            finally
            {
                App.Current.RootVisual.Visibility = System.Windows.Visibility.Visible;
            }
            return await mobileService.LoginWithMicrosoftAccountAsync(session.AuthenticationToken);

        }