Exemple #1
0
        private async Task <bool> ConnectToOneDriveAsync()
        {
            if (null == ODClient)
            {
                this.ODClient = await FormMicrosoftAccountAuth.GetOneDriveClientAsync(Properties.Resources.ONEDRIVE_CLIENT_ID,
                                                                                      new OneDriveScopes[] { OneDriveScopes.ReadWrite });

                if (null == this.ODClient)
                {
                    MessageBox.Show("Failed to connect to OneDrive. Try again later.");
                    return(false);
                }
            }
            return(true);
        }
Exemple #2
0
        private async void buttonLogin_Click(object sender, EventArgs e)
        {
            if (null == ODClient)
            {
                ODClient = await FormMicrosoftAccountAuth.GetOneDriveClientAsync(Properties.Resources.ONEDRIVE_CLIENT_ID,
                                                                                 new OneDriveScopes[] { OneDriveScopes.ReadWrite, OneDriveScopes.Photos, OneDriveScopes.SharedItems, OneDriveScopes.OfflineAccess }, this);

                if (null != ODClient)
                {
                    buttonLogin.Text = "Logout";
                    OnRootFolderChange((RootFolders)comboBoxScope.SelectedIndex);
                }
            }
            else
            {
                ODClient = null;

                Properties.Settings.Default.RefreshToken = null;
                Properties.Settings.Default.Save();

                buttonLogin.Text = "Login";
            }
        }