Esempio n. 1
0
    IEnumerator onOpenSignInDialog()
    {
        UILayout.Instance.BottomOut();
        MainArea.Instance.Hide();
        yield return(new WaitForSeconds(0.6f));

        SignInDialog.Popup();
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="SignInChallengeHandler"/> class.
 /// </summary>
 /// <param name="signInDialog">The underlying SignInDialog that will displayed inside a ContentDialog.</param>
 /// <exception cref="System.ArgumentNullException">signInDialog</exception>
 internal SignInChallengeHandler(SignInDialog signInDialog) // might be public
 {
     if (signInDialog == null)
         throw new ArgumentNullException("signInDialog");
     _signInDialog = signInDialog;
     CredentialSaveOption = CredentialSaveOption.Hidden; // default value
     SetSignInDialogCredentialSaveOption();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SignInChallengeHandler"/> class.
 /// </summary>
 /// <param name="signInDialog">The underlying SignInDialog that will displayed inside a ContentDialog.</param>
 /// <exception cref="System.ArgumentNullException">signInDialog</exception>
 internal SignInChallengeHandler(SignInDialog signInDialog) // might be public
 {
     if (signInDialog == null)
     {
         throw new ArgumentNullException("signInDialog");
     }
     _signInDialog = signInDialog;
     SetSignInDialogCredentialSaveOption();
 }
Esempio n. 4
0
        protected override PSDriveInfo NewDrive(PSDriveInfo drive)
        {
            try
            {
                using (var dialog = new SignInDialog())
                {
                    dialog.Scopes        = new[] { "wl.basic", "wl.signin", "wl.offline_access", "wl.skydrive_update", "wl.contacts_skydrive", "wl.emails" };
                    dialog.ShowInTaskbar = true;
                    dialog.Locale        = "en";
                    dialog.ClientId      = "000000004412E411";

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        OneDriveInfo oneDrive = new OneDriveInfo(drive);
                        oneDrive.Client = new LiveConnectClient(dialog.Session);

                        LiveOperationCompletedEventArgs eventArgs = default(LiveOperationCompletedEventArgs);
                        using (ManualResetEvent signal = new ManualResetEvent(false))
                        {
                            oneDrive.Client.GetCompleted += (s, e) => { eventArgs = e; signal.Set(); };
                            oneDrive.Client.GetAsync("me", signal);

                            signal.WaitOne();
                        }

                        if (eventArgs.Error == null)
                        {
                            foreach (var key in eventArgs.Result.Keys)
                            {
                                WriteVerbose(string.Format("{0}={1}", key, eventArgs.Result[key]));
                            }
                            return(oneDrive);
                        }

                        if (eventArgs.Cancelled)
                        {
                            WriteError(new ErrorRecord(new Exception("Operation cancelled by user."), "503", ErrorCategory.InvalidOperation, null));
                            return(null);
                        }

                        WriteError(new ErrorRecord(new Exception(eventArgs.Error.Message), "200", ErrorCategory.AuthenticationError, null));
                        return(null);
                    }
                    else
                    {
                        WriteError(new ErrorRecord(new Exception("Operation cancelled by user."), "502", ErrorCategory.InvalidOperation, null));
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex.InnerException, "100", ErrorCategory.NotSpecified, null));
                return(null);
            }
        }
 private void Challenge(string url,
                        Action <IdentityManager.Credential, Exception> callback, IdentityManager.GenerateTokenOptions options)
 {
     SignInDialog.DoSignIn(url, (credential, error) =>
     {
         if (error == null)
         {
             ToolBorder.Visibility      = System.Windows.Visibility.Visible;
             LoggedInGrid.Visibility    = System.Windows.Visibility.Visible;
             LoggedInUserTextBlock.Text = credential.UserName;
         }
         callback(credential, error);
     }
                           , options);
 }