]> gitweb.factorcode.org Git - factor.git/commitdiff
Leave oauth alone. Leave her alone!!!
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 12 Mar 2014 05:58:04 +0000 (00:58 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 12 Mar 2014 05:58:04 +0000 (00:58 -0500)
Revert "Revert "oauth: Generate the oauth signature base string the way twitter does it.""

This reverts commit 288156beb6bd09e4d00de03d0be6d41acbd30419.

extra/oauth/oauth.factor

index b0a358dcf0b61ec2308d3999a8c3412b776068de..07fd29e752dbd96cf953546d05c59151d60a031a 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors assocs base64 calendar checksums.hmac
 checksums.sha combinators fry http http.client kernel locals
 make math namespaces present random sequences sorting strings
-urls urls.encoding ;
+urls urls.encoding urls.private checksums ;
 IN: oauth
 
 SYMBOL: consumer-token
@@ -26,13 +26,20 @@ nonce ;
     new
         consumer-token get >>consumer-token
         now timestamp>unix-time >integer >>timestamp
-        random-32 >>nonce ; inline
+        16 random-bytes hex-string >>nonce ; inline
+
+: present-base-url ( url -- string )
+    [
+        [ unparse-protocol ]
+        [ path>> url-encode % ] bi
+    ] "" make ;
 
 :: signature-base-string ( url request-method params -- string )
     [
         request-method % "&" %
-        url present url-encode-full % "&" %
+        url present-base-url url-encode-full % "&" %
         params assoc>query url-encode-full %
+        url query>> [ assoc>query "&" prepend url-encode-full % ] when*
     ] "" make ;
 
 : hmac-key ( consumer-secret token-secret -- key )