mirror of
https://github.com/greenshot/greenshot
synced 2025-07-14 17:13:44 -07:00
OAuth Code cleanup and Dropbox CallbackUrl fix.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2029 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
8f90c54729
commit
66427c3932
2 changed files with 14 additions and 14 deletions
|
@ -88,7 +88,7 @@ namespace GreenshotPlugin.Controls {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkUrl() {
|
private void checkUrl() {
|
||||||
if (browser.Url.ToString().Contains(_oauth.CallbackUrl)) {
|
if (browser.Url.ToString().StartsWith(_oauth.CallbackUrl)) {
|
||||||
string queryParams = browser.Url.Query;
|
string queryParams = browser.Url.Query;
|
||||||
if (queryParams.Length > 0) {
|
if (queryParams.Length > 0) {
|
||||||
//Store the Token and Token Secret
|
//Store the Token and Token Secret
|
||||||
|
|
|
@ -96,7 +96,7 @@ namespace GreenshotPlugin.Core {
|
||||||
protected const string OAuthTimestampKey = "oauth_timestamp";
|
protected const string OAuthTimestampKey = "oauth_timestamp";
|
||||||
protected const string OAuthNonceKey = "oauth_nonce";
|
protected const string OAuthNonceKey = "oauth_nonce";
|
||||||
protected const string OAuthTokenKey = "oauth_token";
|
protected const string OAuthTokenKey = "oauth_token";
|
||||||
protected const string oAauthVerifier = "oauth_verifier";
|
protected const string oAauthVerifierKey = "oauth_verifier";
|
||||||
protected const string OAuthTokenSecretKey = "oauth_token_secret";
|
protected const string OAuthTokenSecretKey = "oauth_token_secret";
|
||||||
|
|
||||||
protected const string HMACSHA1SignatureType = "HMAC-SHA1";
|
protected const string HMACSHA1SignatureType = "HMAC-SHA1";
|
||||||
|
@ -313,7 +313,7 @@ namespace GreenshotPlugin.Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(oauth_verifier)) {
|
if (!string.IsNullOrEmpty(oauth_verifier)) {
|
||||||
parameters.Add(new QueryParameter(oAauthVerifier, oauth_verifier));
|
parameters.Add(new QueryParameter(oAauthVerifierKey, oauth_verifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -419,9 +419,9 @@ namespace GreenshotPlugin.Core {
|
||||||
string response = oAuthWebRequest(Method.POST, RequestTokenUrl, String.Empty);
|
string response = oAuthWebRequest(Method.POST, RequestTokenUrl, String.Empty);
|
||||||
if (response.Length > 0) {
|
if (response.Length > 0) {
|
||||||
NameValueCollection qs = NetworkHelper.ParseQueryString(response);
|
NameValueCollection qs = NetworkHelper.ParseQueryString(response);
|
||||||
if (qs["oauth_token"] != null) {
|
if (qs[OAuthTokenKey] != null) {
|
||||||
this.Token = qs["oauth_token"];
|
this.Token = qs[OAuthTokenKey];
|
||||||
this.TokenSecret = qs["oauth_token_secret"];
|
this.TokenSecret = qs[OAuthTokenSecretKey];
|
||||||
ret = this.Token;
|
ret = this.Token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,7 @@ namespace GreenshotPlugin.Core {
|
||||||
Exception e = new Exception("The request token is not set");
|
Exception e = new Exception("The request token is not set");
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
LOG.DebugFormat("Opening browser for URL: {0}", AuthorizationLink);
|
LOG.DebugFormat("Opening AuthorizationLink: {0}", AuthorizationLink);
|
||||||
OAuthLoginForm oAuthLoginForm = new OAuthLoginForm(this, browserTitle, BrowserWidth, BrowserHeight);
|
OAuthLoginForm oAuthLoginForm = new OAuthLoginForm(this, browserTitle, BrowserWidth, BrowserHeight);
|
||||||
oAuthLoginForm.ShowDialog();
|
oAuthLoginForm.ShowDialog();
|
||||||
Token = oAuthLoginForm.Token;
|
Token = oAuthLoginForm.Token;
|
||||||
|
@ -467,11 +467,11 @@ namespace GreenshotPlugin.Core {
|
||||||
|
|
||||||
if (response.Length > 0) {
|
if (response.Length > 0) {
|
||||||
NameValueCollection qs = NetworkHelper.ParseQueryString(response);
|
NameValueCollection qs = NetworkHelper.ParseQueryString(response);
|
||||||
if (qs["oauth_token"] != null) {
|
if (qs[OAuthTokenKey] != null) {
|
||||||
this.Token = qs["oauth_token"];
|
this.Token = qs[OAuthTokenKey];
|
||||||
}
|
}
|
||||||
if (qs["oauth_token_secret"] != null) {
|
if (qs[OAuthTokenSecretKey] != null) {
|
||||||
this.TokenSecret = qs["oauth_token_secret"];
|
this.TokenSecret = qs[OAuthTokenSecretKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ namespace GreenshotPlugin.Core {
|
||||||
/// <returns>The url with a valid request token, or a null string.</returns>
|
/// <returns>The url with a valid request token, or a null string.</returns>
|
||||||
public string AuthorizationLink {
|
public string AuthorizationLink {
|
||||||
get {
|
get {
|
||||||
return AuthorizeUrl + "?oauth_token=" + this.Token;
|
return AuthorizeUrl + "?" + OAuthTokenKey + "=" + this.Token + "&" + OAuthCallbackKey + "=" + UrlEncode3986(CallbackUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ namespace GreenshotPlugin.Core {
|
||||||
if (querystring.Length > 0) {
|
if (querystring.Length > 0) {
|
||||||
querystring += "&";
|
querystring += "&";
|
||||||
}
|
}
|
||||||
querystring += "oauth_signature=" + NetworkHelper.UrlEncode(sig);
|
querystring += OAuthSignatureKey + "=" + NetworkHelper.UrlEncode(sig);
|
||||||
|
|
||||||
if (querystring.Length > 0) {
|
if (querystring.Length > 0) {
|
||||||
outUrl += "?";
|
outUrl += "?";
|
||||||
|
@ -597,7 +597,7 @@ namespace GreenshotPlugin.Core {
|
||||||
if (querystring.Length > 0) {
|
if (querystring.Length > 0) {
|
||||||
querystring += "&";
|
querystring += "&";
|
||||||
}
|
}
|
||||||
querystring += "oauth_signature=" + NetworkHelper.UrlEncode(sig);
|
querystring += OAuthSignatureKey + "=" + NetworkHelper.UrlEncode(sig);
|
||||||
|
|
||||||
//Convert the querystring to postData
|
//Convert the querystring to postData
|
||||||
if (method == Method.POST) {
|
if (method == Method.POST) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue