private void PluginForm_Shown(object sender, EventArgs e) { try { _roots = new Stack <string>(); Refresh(); var t = GetSavedToken(); if (true) //t == null) //TODO: use refresh token? { var b = new Browser(_api.LoginUrl); if (b.ShowDialog(this) == DialogResult.OK) { if (!string.IsNullOrEmpty(b.Code)) { Cursor.Current = Cursors.WaitCursor; _api.InitTokens(b.Code); SaveToken(_api.OAuth2Token); _path = LoadFiles(null); Cursor.Current = Cursors.Default; } else { MessageBox.Show("Login failed"); DialogResult = DialogResult.Cancel; } } } else { _api.OAuth2Token = t; Cursor = Cursors.WaitCursor; _path = LoadFiles(null); Cursor = Cursors.Default; } labelInfo.Text = string.Empty; } catch (Exception exception) { Cursor = Cursors.Default; MessageBox.Show(exception.Message); DialogResult = DialogResult.Cancel; } }