public static Uri ShowDialog(Uri url, string callBackUrl) { Uri result = null; using (WebAuth wa = new WebAuth()) { wa.StartUrl = url; wa.CallBackUrl = callBackUrl; wa.ShowDialog(); result = wa.Result; } return(result); }
private async void Button1_Click(object sender, EventArgs e) { // creating oAuth-client OAuthClient oAuthClient = new OAuthClientFactory().Create(ConsumerKey.Text, ConsumerSecret.Text); // get requesttoken Token requestToken = await oAuthClient.GetRequestTokenAsync(_callbackUrl); // get the authorize Url Uri url = oAuthClient.GetAuthorizeUrl(requestToken); var verifierUrl = WebAuth.ShowDialog(url, _callbackUrl); Token accessToken = await oAuthClient.GetAccessTokenAsync(requestToken, verifierUrl.OriginalString); AccessKey.Text = accessToken.Key; AccessSecret.Text = accessToken.Secret; Activate(); UserInfo userInfo = null; try { var tc = new TumblrClientFactory().Create <TumblrClient>(ConsumerKey.Text, ConsumerSecret.Text, accessToken); userInfo = await tc.GetUserInfoAsync(); } catch (Exception) { MessageBox.Show("Logon failure", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MessageBox.Show($"Success! the name of your blog is {userInfo.Blogs[0].Name}", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); }