Search code examples
google-fusion-tablesgoogle-oauth

Migrating command line script to FT API 1.0


I have a simple server-side command line python script, based on the now deprecated FT SQL API using Client Login for authorization. Every few hours I refresh my FT by inserting the updated data. It's a small table, 3000 rows.

Read the FT Migration Guide, have a Google User id, enabled the FT API and have an API key, etc. (Switching my Google Maps application to the new API was straight forward)

But I'm confused about how to proceed with migrating a command line python script. I see that OAuth2 is the recommended approach for authentication but it appears to me that this is a much more complicated approach than I truly need. It's not even clear to me that it will work for command line scripts. Truly no need to prompt the user for login info (it's only me). I realize that this must be an "Installed app" and I found the Hello,python example at https://developers.google.com/fusiontables/docs/sample_code#ftAPIv1

Haven't tried this yet but wanted to see if anyone has experience with migrating command line scripts. (PHP would work as well)

In particular I was intrigued by a quote I found here: https://developers.google.com/fusiontables/docs/v1/using

"The Fusion Tables API also supports older authorization options, such as OAuth 1.0, AuthSub, or ClientLogin; however, in most cases we don't recommend using those other options. If your application already uses those options, we recommend migrating to OAuth 2.0 if possible."

Because, frankly I'd rather not switch to OAuth 2 for such a simple task.

UPDATE

Forgot to mention, I run this from cron, every 3 hours. So user input is not really possible. Though as David suggested below a one time user input is doable.


Solution

  • You should be able to use your Client Login token as your auth token for your existing server-side command line app with the new API. You'll also need to include your developer key in the request as the "key" parameter.