private void webBrowser_Navigated(object sender, NavigationEventArgs e) { var accessToken = cloudController.ParseUriForToken(e.Uri); if (accessToken != null) { // Make a call to /account/info to verify that the access token is working. var client = new WebClient(); client.Headers["Authorization"] = "Bearer " + accessToken; var accountInfo = client.DownloadString("https://www.dropbox.com/1/account/info"); MessageBox.Show("Account info: " + accountInfo); } }
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e) { string accessToken; string refresh_token = null; var result = cloudController.ParseUriForToken(e.Url); if (result != null) { if (cloudType == (int)CloudsEnum.OneDrive) { dynamic data1 = JObject.Parse(result); refresh_token = data1.refresh_token; accessToken = data1.access_token; } else { accessToken = result; } CloudUserInfo cloudUserInfo = cloudController.GetAccountInfo(accessToken); if (dbService.IsCloudAlreadyInsered(cloudUserInfo.uid)) { DialogResult dialogResult = MessageBox.Show("This cloud is already inserted.", "Error", MessageBoxButtons.OK); this.Close(); } else { Cloud cloud = new Cloud(); cloud.id = cloudUserInfo.uid; cloud.name = textBoxCloudName.Text; cloud.cloudType = (cloudType == (int)CloudsEnum.DropBox) ? "dropbox" : "box"; cloud.token = accessToken; cloud.refreshToken = refresh_token; cloud.date = DateTime.Now; dbService.InsertCloud(cloud); DialogResult dialogResult = MessageBox.Show("Cloud inserted successfuly.", "Succes", MessageBoxButtons.OK); Logger.Log("The cloud " + cloud.name + " was inserted successfuly!"); this.Close(); } } }