AQXMLParser + OAuth
I've been enjoying using Jim Dovey's excellent AQXMLParser lately, and in fact am giving a talk on it tonight at Sydney CocoaHeads. To use it in a new project, I need to be able to authorise the outbound REST request with some OAuth 1 tokens etc.
OAuth can be a right pain, and the Cocoa implementations aren't awesome. gtm-oauth (the OAuth 1 library from the Google Toolbox for Mac) is a little odd in its implementation, but doing your own OAuth implementation would be so tedious it's one of the better options out there.
It's all pretty easy. Firstly, use gtm-oauth like normal to have your user authorise your app and receive a token.
Next, to make a request, gtm-oauth provides a way to authorise an NSMutableURLRequest, but AQXMLParser uses it's own HTTPMessage class (which wraps the lower level CFHTTPMessage from Core Foundation).
What I have done is extend HTTPMessage to provide a copy of itself as an NSURLRequest, and then write a category that auths that with gtm-oauth and then cribs the headers from that and applies them to the HTTPMessage. It's a little roundabout, but because of the need to sign the whole request and the way that gtm-oauth internals work, anything else would be very complicated. So in use, it looks like this:
#import "HTTPMessage+GTMOAuth.h"
...
GTMOAuthAuthentication * oauth = ...; // setup gtm-oauth like normal
HTTPMessage * myMessage = ...; // create the http request like normal
[myMessage authorizeWithGTMOAuth:oauth];
// now create the parser and use the http message etc. like normal
For now the changes and category are only in my fork, but I have a pending pull request with Jim that I will work out the best way to incorporate them into his master repository. My fork also contains tweaks to work with the latest llvm and ARC (although note neither gtm-oauth nor HTTPMessage or AQXMLParser use ARC, so you'll have to add the -fno-objc-arc compiler flag where appropriate).
gtm-outh: http://code.google.com/p/gtm-oauth/
My fork of aqtoolkit: https://github.com/aufflick/aqtoolkit
02:25 AM, 02 Aug 2012 by Mark Aufflick Permalink | Comments (0)
supervisord supervisorctl cheat sheet
On my new server I made the switch from daemontools to supervisor. As if to make daemontools users feel at home the documentation for supervisorctl use is a bit thin :)
So far my biggest gotcha was that after adding a new .conf file in your includes (or to the main file itself, but you wouldn't do that would you?) is that you need to do *both* of the following:
> supervisorctl reread
new.app.conf: available
> supervisorctl update
new.app.conf: added process group
> supervisorctl
new.app RUNNING ...
haproxy
Unfortunately supervisor doesn't offer a way to provide a custom restart command, so doing an uninterrupted haproxy restart via supervisor isn't possible. Instead make sure you have autorestart set to unexpected (the default) rather than true (which is what I usually do) - that way if you want a clean haproxy restart you can just do it yourself at the commandline using the -sf option as normal.
11:14 PM, 25 Mar 2012 by Mark Aufflick Permalink | Comments (0)
SAPI Cocoa SDK
01:13 AM, 24 Mar 2012 by Mark Aufflick Permalink | Comments (0)
Archive
| May 2013 | ||||||
| S | M | T | W | T | F | S |
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
March 2012
February 2012
November 2011
October 2011
April 2011
March 2011
January 2011
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
September 2003
August 2003
Blog Categories
software (40)..cocoa (21)
..heads up 'tunes (5)
..ruby (6)
..lisp (4)
..perl (4)
..openacs (1)
mac (21)
embedded (2)
..microprocessor (2)
..avr (1)
electronics (3)
design (1)
photography (26)
..black and white (6)
..A day in Sydney (18)
..The Daily Shoot (6)
food (2)
Book Review (2)
Notifications
Request notifications






