OAuth refactoring, making Photobucket work.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2073 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-09-20 11:37:47 +00:00
commit 8b8024e20c
5 changed files with 185 additions and 140 deletions

View file

@ -137,23 +137,19 @@ namespace GreenshotImgurPlugin {
}
} else {
OAuthSession oAuth = new OAuthSession();
oAuth.BrowserWidth = 650;
oAuth.BrowserHeight = 500;
OAuthSession oAuth = new OAuthSession(ImgurCredentials.CONSUMER_KEY, ImgurCredentials.CONSUMER_SECRET);
oAuth.BrowserSize = new Size(650, 500);
oAuth.CallbackUrl = "http://getgreenshot.org";
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 = ImgurCredentials.CONSUMER_KEY;
oAuth.ConsumerSecret = ImgurCredentials.CONSUMER_SECRET;
oAuth.UserAgent = "Greenshot";
oAuth.LoginTitle = "Imgur authorization";
//oAuth.UseHTTPHeadersForAuthorization = false;
oAuth.Token = config.ImgurToken;
oAuth.TokenSecret = config.ImgurTokenSecret;
try {
LOG.DebugFormat("Test: {0}", oAuth.oAuthWebRequest(HTTPMethod.GET, "http://api.imgur.com/2/account", null));
responseString = oAuth.oAuthWebRequest(HTTPMethod.POST, "http://api.imgur.com/2/account/images.xml", uploadParameters);
LOG.DebugFormat("Test: {0}", oAuth.MakeOAuthRequest(HTTPMethod.GET, "http://api.imgur.com/2/account", null));
responseString = oAuth.MakeOAuthRequest(HTTPMethod.POST, "http://api.imgur.com/2/account/images.xml", uploadParameters);
} catch (Exception ex) {
LOG.Error("Upload to imgur gave an exeption: ", ex);
throw ex;