In Issue #475 @steveklabnik expressed a desire to have a mech script that can grab an API key for you. I dig automation and haven't had a chance to play with Mechanize yet. I'll try and tackle this in the upcoming week and send over a pull request.
Let me know if you need a hand with this. I've got a hack-ish script somewhere on my computer.