Friday, February 10, 2017

How to get Open Live Writer working with Blogger

Wow – I didn’t blog at all in 2016!  While I’m certain that falls squarely on me, perhaps a small part of it is related to a bug connecting to Blogger (formerly Blogspot) blogs in my favorite blogging software – Open Live Writer.  This blog post explains the workaround and how I figured it out.  Hopefully this issue will get patched by the Open Live Writer team and the workaround won’t be needed in the future.

The Issue

Trying to connect to a Google Blogger blog with Open Live Writer v0.6.0.0 doesn’t work (this is the latest version as of this post).  Clicking the Sign In button brings the user to this URL:

https://accounts.google.com/o/oauth2/auth?access_type=offline&response_type=code&client_id=PASTE_YOUR_CLIENT_ID_HERE&redirect_uri=http:%2F%2Flocalhost:59530%2Fauthorize%2F&scope=https:%2F%2Fwww.googleapis.com%2Fauth%2Fblogger%20https:%2F%2Fpicasaweb.google.com%2Fdata
Notice the client_id value “PASTE_YOUR_CLIENT_ID_HERE” in that URL!  That’s definitely not right, and it breaks the attempt to authenticate to Google via OAuth.

The Workaround

I tried installing several different versions of Open Live Writer via Chocolatey.  I found that the issue is also present in versions v0.5.1.4, and v0.5.1.3, but version v0.5.1.2 works.  The best way to get Open Live Writer working with Blogger is to install Chocolatey, and then run this command:

choco install openlivewriter -version 0.5.1.2 -force

 

That will install the correct version of Open Live Writer that we need to authenticate. However, you can’t run Open Live Writer from the main shortcut. Open Live Writer uses Squirrel which is a tool that assists with automatically updating software when it is launched. Almost all the time this is great, but for our purposes it will not help since we want to run the exact version we’ve just installed.

 

So run this, and you should be able to authenticate with Google’s Blogger service via OAuth:

 

%localappdata%\OpenLiveWriter\app-0.5.1.2\OpenLiveWriter.exe

 

Once you’ve authenticated to Blogger, you can quit out and then use the Start Menu shortcut. This will run the Squirrel updater, and your system will be updated to the latest version which is v0.6.0.0 as of this writing.

 

How I Figured This Out

 

It was a bit of brute force. First I cloned the repository for Open Live Writer from here. Then, I opened up the solution in Visual Studio 2015 Community Edition and searched for the string “PASTE_YOUR_CLIENT_ID_HERE” in all files. This led me to the src/managed/OpenLiveWriter.BlogClient/Clients/GoogleBloggerv3Secrets.json file. When I noticed that the file was called “Secrets” it made me think that perhaps this was a compilation/deployment issue. I looked into the .gitignore file at the root of the repo, and sure enough the GoogleBloggerv3Secrets.json file was specifically ignored.

 

Therefore, my theory was that the person who packaged up Open Live Writer versions v0.6.0.0 didn’t have the Secrets file updated on their machine. This leads to the idea that probably someone in the past DID have it updated, so I tried successive earlier and earlier versions until I hit on v0.5.1.2 working (I would have tried a bisect approach but there were only four historical releases).

 

Why was this broken?

 

It’s good that the Open Live Writer team moved the Google Blogger secrets out of their public repo. However, this makes it difficult for individuals to build a complete version of the app. A good solution could be to use a CI/CD build solution – I wonder if the Microsoft team might look into Visual Studio Team Services? I suspect they could get a good deal from that vendor.

 

I wrote up the bug in Issue #561.

There is still an issue with using images and Open Live Writer with a Blogger account due to the Picassa shutdown.  I will post again if I find a workaround for that issue.

No comments:

Post a Comment