Using PowerShell and oAuth

the oAuth Flow

Like most of my posts here, I’m going to try to make something sound easy, when in reality I’ve spent months crying into my coffee trying to understand it. In truth, I’ve been trying to get oAuth to work for more than a year now.

It all started with a simple goal, I just wanted to check my blog stats easily using WordPress’s REST API, and I wanted to do it from PowerShell, should be simple, right? WRONG

My initial issue was that I didn’t want to understand oAuth, I just wanted to copy and paste some stuff and hope that it worked. I can tell you now that I’ve worked it out, it really isn’t that difficult, but knowing what’s happening will make it all much easier.

What is oAuth?

oAuth was made to solve a problem, that of sharing information between two different web services. We need oAuth because a user may want to right click a file from and post it on Facebook with one click, for instance. Or have their Twitter send a Tweet when they update their Blog on WordPress. oAuth is a crucial verification step when tying two services together, and it’s worth the time to spend learning how it works. Furthermore, most of the coolest REST APIs out there require you to authenticate using oAuth in order to even use them.

Now, let’s see what the steps are to get your application (or script) linked to a service that uses oAuth.
Continue reading

PushBullet + PowerShell = PowerBullet!

A friend and colleague of mine, Chris Townsend were talking over lunch recently, when he lamented that during a very long scripted process, he would have to manually check back in for status checks to see how this process was going, and might waste a whole weekend in front of the keyboard.  We began trying to think of ways to get notifications if he needed to intervene and manually do something.

We talked about e-mails, but I think it wouldn’t work because of no open SMTP relay.  Then we wondered about sending a text, and I was reminded of PushBullet.  If you’ve never heard of it before, it is a very cool service you can install on your desktop, tablets, phones and even web browsers to recieve and send push notifications.  Your friends can sign up under one single Push list and send each other notifications or cool links.  You can also use it in your scripts, provided you’d like to dig into the SDK and setup your own framework with the API.

Introducing PowerBullet v 1.0

I present to you the (mostly) finished version of my implementation of PushBullet, which I call PowerBullet.  It currently contains only one function, Send-PushMessage, which will send pushes to all of your devices.  In v 2.0, you’ll be able to specify which device a message goes to.  Currently, you can send the following types of messages:

  • Send a Message/ Note (contains a title, and body text) – works
  • Send an address (Will open in the default maps application) – works
  • Send a file which pre-exists on the web – works
  • Send a link (will open as a URL) – works
  • Send a checklist*
  • Upload and send a file*

There are currently issues with sending a Checklist and Uploading a file.  Due to the more complex nature of these tasks, I plan to fully implement them in v2.0.  For now, the code exists and the function will mostly work, but error out.  If you spot the hole in my logic, let me know!

Download PowerBullet here!

To start off, I need to give credit where credit is due: Continue reading