Scanning API Receiver with Firebase DB
A simple Meraki Location Scanning API receiver which stores the data in a Google Firebase database.
Background
The Scanning API is data-rich and operates using custom POST model. This means that if users want to analyze and process the data, they must host and store it in a database of their choosing. This guide walks through how to use a receiver developed by dexterlabora which is designed to store the received API data in a Google Firebase database.
Pre-requisites
Install
Clone the project and install the dependencies
git clone https://github.com/dexterlabora/MerakiLocationFirebase.git
cd MerakiLocationFirebase
cd functions
npm install
Install Firebase Tools globally. Requires sudo if on a Mac.
sudo npm install -g firebase-tools
Update your Validator and Secret.
- Open
functions/index.js
and set the validator and secret variables. The validator is provided on the Meraki Dashboard page when enabling the Scanning API. The secret is defined by you and must match the configuration in the Meraki Dashboard.
nano index.js
~~~~~~~~~~
const functions = require('firebase-functions');
const firebase = require('firebase');
const validator = "8e0846499d9a3f6c23fBoGus4c25b9d6325035f5" // Your Validator provide by Meraki
const secret = "YourSecret"; // Your self defined secret
~~~~~~~~~~
Deploy the app to Google Firebase
- You will have to login the first time. A link will be presented to perform a Google Oauth process.
firebase login
firebase deploy
Deployment Results
=== Deploying to 'merakilocation'...
i deploying database, functions, hosting
i database: checking rules syntax...
✔ database: rules syntax for database merakilocation is valid
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (1.46 KB) for uploading
✔ functions: functions folder uploaded successfully
i hosting: preparing public directory for upload...
✔ hosting: 2 files uploaded successfully
i database: releasing rules...
✔ database: rules for database merakilocation released successfully
i functions: updating function scanning...
✔ functions[scanning]: Successful update operation.
Function URL (scanning): https://us-central1-merakilocation.cloudfunctions.net/scanning
✔ Deploy complete!
Project Console: https://console.firebase.google.com/project/merakilocation/overview
Hosting URL: https://merakilocation.firebaseapp.com
Open the Function URL provided in your web browser. It should respond with the validator key you provided in the script file.
Finally, update your Meraki network with a new Post URL for the Scanning API.
- Meraki Dashboard -> Network-wide Settings -> Configure -> General -> Scanning API
- Post URL: the Function URL address
(e.g. https://us-central1-merakilocation.cloudfunctions.net/scanning) - Secret: Your secret that was defined in the script file.
- Post URL: the Function URL address
Login to your Firebase Console and observe the database for your project.
Success!
Now that you have data being received into your database, use the platform to build front-end applications or trigger workflows as desired.
More Info
Scanning API Docs