Showing posts with label Windows XP. Show all posts
Showing posts with label Windows XP. Show all posts

Setup GoogleCL on WinXP

UPDATE: These instructions were originally written for version 0.9.5. I have started updating them with differences found in the newer 0.9.7 version of GoogleCL. If you find more differences I should mention, please leave a comment. Thanks!

Google just announced their new command line utility for Google services. The GoogleCL project is an Open Source project hosted on Google Code. Although the project page is obviously slanted toward Linux, I figured it's Python so it shouldn't be too hard to run on Windows too. Here's what I had to do to get things setup on Windows XP Professional SP3.

First some downloads:

Note: GoogleCL requires Python 2.5 or 2.6.

Install Python

Run the .msi file to install Python. I installed to C:\dev\Python\Python25 and I added C:\dev\Python\Python25 to my PATH for easier command line access to python.exe.

Install Google Data API

I unzipped gdata-2.0.10.zip to C:\dev\Python\gdata-2.0.10 and ran setup.py install from C:\dev\Python\gdata-2.0.10. No problems encountered there.

C:\dev\Python\gdata-2.0.10>setup.py install

Install GoogleCL

I unzipped googlecl-0.9.5.tar.gz to C:\dev\Python\googlecl-0.9.5 and ran setup.py install from C:\dev\Python\googlecl-0.9.5. Again, no problems.

C:\dev\Python\googlecl-0.9.5>setup.py install

Write a "google" script

Next I wanted a "google" command that would be as easy to run from the Windows command line as the Linux examples were. I wrote this google.cmd file and put it on my PATH:

@echo off
SET googlecl_home=C:\dev\Python\googlecl-0.9.5\src

python %googlecl_home%\google %*

Now, running google docs list got me a prompt for my user name. But instead of prompting for a password, GoogleCL uses OAuth. This is the message I got:

Note: this was true as of GoogleCL v0.9.5 - see below for v0.9.7

(Hint: You can automatically launch your browser by adding "auth_browser = " to your config file under the GENERAL section, or define the BROWSER environment variable.)

Please log in and/or grant access via your browser at
https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=[token removed]
then hit enter.

Well, obviously that wouldn't do. It would have been nice if it had told me where to find that config file, but it wasn't hard to locate. As alert reader Brian B. pointed out, the first time you run GoogleCL it will try to locate the config file and if it doesn't find one, it will tell you the path and create the file for you. Mine was in C:\Documents and Settings\itruett\.googlecl.

The path for my browser, Google Chrome, is a little less intuitive. I found it, and added this to my GoogleCL config file:

auth_browser = C:\Documents and Settings\itruett\Local Settings\Application Data\Google\Chrome\Application\chrome.exe

The next time I ran GoogleCL, Chrome launched and showed me the authorization page. A couple of clicks and that was done. I had to authorize once for each Google service.

Update: v0.9.7 Browser Authorization

The first time you try to access each service, GoogleCL will display this message:

Please log in and/or grant access via your browser at
https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=[token removed]
then hit enter.

GoogleCL will launch your default browser to the authorization page where you can grant your approval. You only need to do this once for each service.

Version 0.9.5 required auth_browser to be set in your GoogleCL config file in order to launch the browser automatically. Reader Joe Ledvina reported that auth_browser causes problems with version 0.9.7. Removing auth_browser will allow your default browser to launch. I believe this to be a bug and reported it as such in a comment to issue #51.

One complaint I have about the authorizations is that they just show up as "anonymous" in My Account. If I use GoogleCL for the same account from two different computers, I don't know how I'd be able to tell the difference if I wanted to revoke access for one of them.

No, unfortunately I did not write this post offline and then submit it with GoogleCL. Maybe next time. Now I wonder if I can get it to run on Android.