This article is part of a series of articles being written to explore the possibilities between Intel Galileo and the Mashery API Network. In this article, I will be discussing how Node.js can be used with OAuth to authenticate with any of the 40+ APIs in the Mashery API Network.
Introducing Galileo + Node.js
As mentioned in my previous articles on the topic of Node.js and the Mashery API Network, one of the benefits of Intel® Galileo is that the development board runs a light-weight version of Linux called Yocto and is also compatible with Arduino components and sketches. Node.js is a powerful, easy to use platform for easily building fast, scaleable network applications and has caught on with the web development community due to it's many advantages and it commonly managed, installed, updated via a command-line tool known as NPM (Node Package Manager). Using the Node Package Manager website, developers can install (or contribute) a wide variety of freely available libariers and utilities which make Node.js development more productive.
Up and Running with Node.js and Intel Galileo
Several open-source libraries and packages have been provided by the web community to make it easy to get up and running with Node.js on Galileo. Lets take a look at a few of these now. The Intel development community has also been at work sharing knowledge around how to best setup and utilize Node. If you have an older version of Galileo, you may need to update your SDCard image using these instructions. Those new to Galileo should start with SparkFun's or Intel's getting started guides. Using Node productively will also require terminal access and wireless or ethernet connectivity.
Exploring Intel Galileo Node.js Packages
Back to Mashery API Network
The purpose of introducing Node.js and the above instructional materials is to set the stage for connecting and authenticating with the 40+ public REST APIs provided by the Mashery API Network. These APIs are freely available to developers using Intel® Galileo and may be used to build a variety of sample applications including fetching the weather, sports data (perhaps to show World Cup scores on an LED), news and various other activities. With a single account, developers authenticated with Mashery can easily log into and register apps with any of the listed APIs.
OAuth for Node.js
In order to use these Mashery APIs from a Galileo board, OAuth authentication will be required. Node.js has several useful, freely available packages which include OAuth support including Node-OAuth and Passport. These packages, like Galileo-io, may be installed on your board using Node Package Manager. Using your OAuth library of choice, you will need to fill-in your authentication parameters using the provided registration information you got when applying for an app-key from your preferred Mashery API.
Here is an example using the ESPN API:
With these registration details, having followed the provided instructions for Node.js and installed your OAuth system of choice, you will be able to authenticate your app and begin making calls to ESPN or your API of choice.