private async void Form1_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Settings.Default.RefreshToken)) { try { var authForm = new LiveAuthForm(ClientId); if (authForm.ShowDialog(this) == DialogResult.OK) { _liveRestClient = new LiveRestClient(ClientId, ClientSecret); await _liveRestClient.InitAsync(authForm.AuthorizeCode); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { _liveRestClient = new LiveRestClient(ClientId, ClientSecret, Settings.Default.RefreshToken); await _liveRestClient.RefreshTokensAsync(); } if (_liveRestClient != null) { if (Settings.Default.RefreshToken != _liveRestClient.RefreshToken) { Settings.Default.RefreshToken = _liveRestClient.RefreshToken; Settings.Default.Save(); } _oneClient = new OneDriveClient(_liveRestClient, RootFolderId); } }
public OneDriveClient(LiveRestClient liveRestClient, string rootFolderId) { _liveRestClient = liveRestClient; if (string.IsNullOrEmpty(rootFolderId)) { _rootFolderId = "/me/skydrive"; } else { _rootFolderId = rootFolderId; } }