some parameters are optionals. signature still bad

Signed-off-by: Luca Fulchir <luca@fulchir.it>
parent a24e0282
include "OAuth1Data.iol"
type OAuth1Init:void {
.location :string
.method :string
.consumer_key :string
.secret :string
}
interface OAuth1Interface {
RequestResponse:
RequestToken (OAuth1Locations) (string)
RequestToken (OAuth1Init) (string)
}
outputPort OAuth1 {
......
......@@ -10,8 +10,8 @@ main
data.location = "http://api.dropbox.com/1/oauth/request_token";
//data.location = "http://codepedia.eu/oauth";
data.method = "post";
data.callback = "";
createSecureToken@SecurityUtils(void)(data.consumer_key);
data.consumer_key = "27250pnzil7tmhx";
data.secret = "6yj3c6mjbdixm6i";
// send the message
RequestToken@OAuth1 (data) (answer);
......
......@@ -2,20 +2,9 @@
type OAuth1Locations:void {
.location :string
.method :string
.callback :string
.callback? :string
.consumer_key :string
}
type OAuth1TokenReq:void {
.oauth_callback :string
.oauth_version :string
.oauth_signature_method :string
.oauth_consumer_key :string
.oauth_timestamp :string
.oauth_nonce :string
.oauth_signature :string
}
type OAuthTkn:void {
.Authorization :string
.secret? :string
}
interface OAuth1DataInterface {
......
......@@ -27,12 +27,16 @@ scope (error_handler) {
// a little too much as a nonce, but it's easier this way :p
createSecureToken@SecurityUtils(void)(oauth_nonce);
toSort.item[0] = "oauth_consumer_key=" + where.consumer_key;
toSort.item[1] = "oauth_signature_method=HMAC-SHA1";
toSort.item[2] = "oauth_timestamp=" + tmp_timestamp;
toSort.item[3] = "oauth_nonce=" + oauth_nonce;
toSort.item[4] = "oauth_version=1.0";
//toSort.item[5] = "oauth_callback=" + where.callback;
toSort.item[0] = "oauth_signature_method=HMAC-SHA1";
toSort.item[1] = "oauth_timestamp=" + tmp_timestamp;
toSort.item[2] = "oauth_nonce=" + oauth_nonce;
toSort.item[3] = "oauth_version=1.0";
toSort.item[4] = "oauth_consumer_key=" + where.consumer_key;
count = 4;
if (is_defined(where.callback)) {
count = count + 1;
toSort.item[count] = "oauth_callback=" + where.callback
};
sort@StringUtils (toSort) (sorted);
......@@ -40,13 +44,16 @@ scope (error_handler) {
toEncode.input = where.location;
encode@URLEncoder (toEncode) (encodedLocation);
toHash.secret = "&";
toHash.secret = "";
if ( is_defined(where.secret))
toHash.secret = where.secret;
toHash.secret = tohash.secret + "&";
toHash.data = where.method + "&" + encodedLocation + "&";
tmp = "";
for (i = 0, i < 4, i++) {
for (i = 0, i < count, i++) {
tmp = tmp + sorted.item[i] + "&"
};
tmp = tmp + sorted.item[4];
tmp = tmp + sorted.item[count];
toEncode.input = tmp;
encode@URLEncoder (toEncode) (encodedParams);
toHash.data = toHash.data + encodedParams;
......@@ -55,7 +62,7 @@ scope (error_handler) {
toEncode.input = tmpSignature;
encode@URLEncoder (toEncode) (signature);
println@Console(">>>>>" + toHash.data + ">>>>" + signature) ();
// println@Console(">>>>>" + toHash.data + ">>>>" + signature) ();
postString = "OAuth " +
"oauth_consumer_key=\"" + where.consumer_key + "\"," +
......@@ -63,8 +70,10 @@ scope (error_handler) {
"oauth_timestamp=\"" + tmp_timestamp + "\"," +
"oauth_nonce=\"" + oauth_nonce + "\"," +
"oauth_version=\"1.0\"," +
"oauth_signature=\"" + signature + "\""
//"oauth_callback=\"" + where.callback + "\"," +
"oauth_signature=\"" + signature + "\"";
if ( is_defined(where.callback))
postString = postString +
"oauth_callback=\"" + where.callback + "\","
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment