Some oAuth fixes for Imgur & Photobucket. Still having problems with Photobucket...

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2026 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-09-12 12:43:02 +00:00
commit f447fb8b72
11 changed files with 165 additions and 118 deletions

View file

@ -134,9 +134,7 @@ namespace GreenshotImgurPlugin {
uploadRequest.Append(EscapeText(System.Convert.ToBase64String(imageData, 0, dataLength)));
// add type
uploadRequest.Append("&type=base64");
// add key
uploadRequest.Append("&key=");
uploadRequest.Append(IMGUR_ANONYMOUS_API_KEY);
// add title
if (title != null) {
uploadRequest.Append("&title=");
@ -151,6 +149,9 @@ namespace GreenshotImgurPlugin {
string responseString;
if (config.AnonymousAccess) {
// add key
uploadRequest.Append("&key=");
uploadRequest.Append(IMGUR_ANONYMOUS_API_KEY);
url = config.ImgurApiUrl + "/upload";
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(url);
@ -171,10 +172,12 @@ namespace GreenshotImgurPlugin {
} else {
url = config.ImgurApiUrl + "/account/images";
OAuthHelper oAuth = new OAuthHelper();
oAuth.BrowserWidth = 650;
oAuth.BrowserHeight = 500;
oAuth.CallbackUrl = "http://getgreenshot.org";
oAuth.AccessTokenUrl = "https://api.imgur.com/oauth/access_token";
oAuth.AuthorizeUrl = "https://api.imgur.com/oauth/authorize";
oAuth.RequestTokenUrl = "https://api.imgur.com/oauth/request_token";
oAuth.AccessTokenUrl = "http://api.imgur.com/oauth/access_token";
oAuth.AuthorizeUrl = "http://api.imgur.com/oauth/authorize";
oAuth.RequestTokenUrl = "http://api.imgur.com/oauth/request_token";
oAuth.ConsumerKey = "fill-in";
oAuth.ConsumerSecret = "fill-in";
oAuth.UserAgent = "Greenshot";
@ -291,31 +294,5 @@ namespace GreenshotImgurPlugin {
} catch {}
}
public static void ImgurOAuthExample() {
OAuthHelper oAuth = new OAuthHelper();
oAuth.CallbackUrl = "http://getgreenshot.org";
oAuth.AccessTokenUrl = "https://api.imgur.com/oauth/access_token";
oAuth.AuthorizeUrl = "https://api.imgur.com/oauth/authorize";
oAuth.RequestTokenUrl = "https://api.imgur.com/oauth/request_token";
oAuth.ConsumerKey = "907d4455b8c38144d68c4f72190af4c40504a0ac7";
oAuth.ConsumerSecret = "d33902ef409fea163ab755454c15b3d0";
oAuth.UserAgent = "Greenshot";
if (string.IsNullOrEmpty(config.ImgurToken)) {
LOG.Debug("Creating Imgur Token");
oAuth.getRequestToken();
if (string.IsNullOrEmpty(oAuth.authorizeToken("Imgur authorization"))) {
return;
}
string accessToken = oAuth.getAccessToken();
config.ImgurToken = oAuth.Token;
config.ImgurTokenSecret = oAuth.TokenSecret;
} else {
LOG.Debug("Using stored Imgur Token");
oAuth.Token = config.ImgurToken;
oAuth.TokenSecret = config.ImgurTokenSecret;
}
System.Windows.Forms.MessageBox.Show(oAuth.oAuthWebRequest(OAuthHelper.Method.GET, "http://api.imgur.com/2/account", null));
}
}
}