Being the blog of Pete Hopkins. This pirate kills fascists.

Sunday, August 27

Authenticating to Google Accounts from the Command Line

The beta version of Blogger uses GData for its API and Google Accounts for logins, which means that it requires the GoogleLogin authorization scheme on API requests. This is more secure, but slightly tougher to work with than HTTP Basic authorization.

Sure, there are libraries (Java and C#) for handling this, but where’s the fun in that? Here’s how to do the API using just curl and sed, in a delightful one-liner:

curl -H "`curl -s -d Email=e-mail address -d Passwd=password -d source=your app name -d service=blogger https://www.google.com/accounts/ClientLogin | sed -n -e \"s/Auth=\(.*\)/Authorization: GoogleLogin auth=\1/p\"`" http://beta.blogger.com/feeds/blog id/posts/full

Note that for the e-mail address, you’ll need to replace “@” with “%40” as per URL encoding.

3 comments:

  1. Anonymous9:11 AM

    Pete, not sure , but your templates looks all screwy.. tehres an overlap with the frames (?) and blog content !!

    ReplyDelete
  2. Anonymous10:28 AM

    Yeah, my personal blog is sorta the one place where I don't bother getting things to look right in IE.

    ReplyDelete
  3. Anonymous9:04 PM

    hehehe.. I totally understand, but then again.. at certain times of the day, users maybe behind an enterprise (AKA IE).

    with FF NP

    ReplyDelete