On Aug 4, 3:54 pm, Cameron Kaiser <spec...@floodgap.com> wrote:
> ITYM "twurl"

Could well have been.  I seem to remember spending ages installing
dependencies with "gem install" (few of them appeared to be available
in Debian packages) and eventually ran into a brick wall where the
versions required just didn't seem to be available from wherever "gem
install" gets them from.

Dave Ingram <d...@dmi.me.uk> wrote:
> > I'm in the middle of tidying up a python-based oauth command-line client

Cameron Kaiser again:
> I'll also throw in a plug for TTYtter, which has no dependencies other than

Thanks for the suggestions, but actually I think I've managed to fix
things without switching to something completely different.

Main thing was, I'd either misread, or just failed to read, the
documentation for curl's "-d" option.  It needs to be URL-encoded
before passing to curl.  I am how stuffing the text I want to send
through the following; probably overkill, but it seems to work:

TWEET="$(echo -n "$MSG" | head -c140 | od -An -tx1 -v | tr '\n' ' ' |
sed 's/^/ /;s/[^0-9A-Fa-f]/ /g;s/  *$//;s/  */%/g')"

Basically, it %-encodes every character.

The other thing I fixed was oauth-proxy itself.  Including the status=
parameter in the Authorization header does seem to break things
sometimes, probably depending on which special characters are included
(and probably not properly escaped) in the value.  This patch seems to
fix that:

--- oauth/oauth.py.orig   2010-08-04 20:06:55.000000000 +0100
+++ oauth/oauth.py        2010-08-04 16:16:42.000000000 +0100
@@ -118,12 +118,22 @@
                 parameters[k] = v
         return parameters

+    # get only oauth parameters
+    def get_oauth_parameters(self):
+        parameters = {}
+        for k, v in self.parameters.iteritems():
+            # ignore oauth parameters
+            if k.find('oauth_') == 0:
+                parameters[k] = v
+        return parameters
+
     # serialize as a header for an HTTPAuth request
     def to_header(self, realm=''):
         auth_header = 'OAuth realm="%s"' % realm
         # add the oauth parameters
-        if self.parameters:
-            for k, v in self.parameters.iteritems():
+        parameters = self.get_oauth_parameters()
+        if parameters:
+            for k, v in parameters.iteritems():
                 auth_header += ', %s="%s"' % (k, v)
         return {'Authorization': auth_header}


With these two fixes, I haven't yet had any problems.  Thanks for the
help!

--Charles

Reply via email to