views:

38

answers:

1

I want to add entries to my RESTful Rails blog using HTTP POST requests. I have a script that does this easily enough, but it only works for my development app because I don't require it to authenticate.

Now that I'm publishing my site, I obviously need to authenticate my uploads before posting them. The rest of the admin stuff is behind filters that check for OpenId authentication.

The problem: OpenId doesn't seem to lend itself to non-GUI authentication. Maybe I'm missing something.

Is there a way to authenticate my POST request via OpenId?

+1  A: 

Technically, you'd have to implement a client in your script.

The script would have to:

  1. Start the authentication on your blog. Your blog should redirect to the OP site.
  2. Authenticate with the OP using whatever method the OP supports.
  3. Follow the redirect to return_to address.

At this point, the script should be authenticated with your blog, and it'd just have to store the session cookie. Subsequent requests can be used with this cookie, so that the script will be authenticated.

If your blog supports it (i.e. doesn't reject uninitiated requests), you could also substitute step 1 with manual discovery and redirection using an RP library.

Mewp
Okay excellent. Follow-up question (but I'm accepting this answer): can I shell out any of this to curl or wget? I've not messed much with them and don't know how easy it is to do all this redirection/cookie storing using the command line.
David Jacobs
curl can be set to follow redirections, so yes, you can. From the command line, it can also automatically store cookies. Example: `curl --location --cookie-jar cookies.txt http://provider.com/endpoint`. Read the manual for information on how to send POST requests if you need them (--data parameter).
Mewp