-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOAuthDialog.cs
More file actions
110 lines (99 loc) · 3.2 KB
/
OAuthDialog.cs
File metadata and controls
110 lines (99 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web;
using Twitterizer;
namespace uStatus
{
public partial class OAuthDialog : Form
{
private string cKey;
private string cSecret;
private string uToken;
private string uSecret;
private string aToken;
private string aSecret;
public string ConsumerKey
{
get { return cKey; }
}
public string ConsumerSecret
{
get { return cSecret; }
}
public string UserToken
{
get {
if (uToken != "") return uToken;
else return null;
}
}
public string UserSecret
{
get {
if (uSecret != "") return uSecret;
else return null;
}
}
public OAuthDialog()
{
InitializeComponent();
this.cKey = Properties.Settings.Default.CKey;
this.cSecret = Properties.Settings.Default.CSecret;
this.uToken = Properties.Settings.Default.UToken;
this.uSecret = Properties.Settings.Default.USecret;
}
public OAuthTokens CreateAccessToken()
{
OAuthTokens token = new OAuthTokens();
token.ConsumerKey = this.ConsumerKey;
token.ConsumerSecret = this.ConsumerSecret;
token.AccessToken = this.UserToken;
token.AccessTokenSecret = this.UserSecret;
return token;
}
private void button1_Click(object sender, EventArgs e)
{
OAuthTokenResponse response =
OAuthUtility.GetRequestToken(cKey, cSecret, "oob");
this.aToken = response.Token;
this.aSecret = response.TokenSecret;
System.Diagnostics.Process.Start("https://twitter.com/oauth/authorize?oauth_token=" + aToken);
}
private void bNext_Click(object sender, EventArgs e)
{
try
{
OAuthTokenResponse response = OAuthUtility.GetAccessToken(cKey, cSecret, aToken, tbPinNumber.Text);
this.uToken = response.Token;
this.uSecret = response.TokenSecret;
Properties.Settings.Default.UToken = response.Token;
Properties.Settings.Default.USecret = response.TokenSecret;
Properties.Settings.Default.Save();
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
catch (TwitterizerException tx)
{
}
}
private void tbPinNumber_TextChanged(object sender, EventArgs e)
{
if (tbPinNumber.Text.Length == 7) bNext.Enabled = true;
else bNext.Enabled = false;
}
private void button3_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Close();
}
private void OAuthDialog_Load(object sender, EventArgs e)
{
}
}
}