particle-iot/google-cloud-datastore-tutorial

Name: google-cloud-datastore-tutorial

Owner: Particle

Description: A demonstration of how to store Particle device data in Google Cloud Datastore

Created: 2016-09-12 23:06:25.0

Updated: 2018-04-02 19:34:58.0

Pushed: 2018-01-03 18:28:47.0

Homepage: null

Size: 7

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Particle –> Google Cloud Pub/Sub –> Datastore Tutorial

This tutorial code is intended to allow data to flow from Google Cloud Pub/Sub to Google Cloud Datastore. This is part of a larger tutorial for sending data from Particle devices into a hosted database.

You can find the full documentation on the Particle <> Google Cloud integration on our docs .

Prerequisites

Before this script will become useful to you, please make sure you have done all of the following:

1) Have Particle device(s) collecting data and publishing events

2) Have a Google Cloud Platform account with a project and a Pub/Sub topic

3) Enabled the Google Cloud Platform integration on Particle

4) Created a Google Cloud Platform private key

5) Created a Google Cloud Pub/Sub subscription

For all required steps, check out the full tutorial

Setup and configuration
Clone the repository

git clone https://github.com/spark/google-cloud-datastore-tutorial.git

Add your Private Key

Create a file in the root of your local repository called gcp_private_key.json

Next, paste in the contents of your Google Cloud Platform JSON private key. It should look something like this:


ype": "service_account",
roject_id": "[GOOGLE CLOUD PLATFORM PROJECT ID]",
rivate_key_id": "[PRIVATE_KEY_ID]",
rivate_key": "[PRIVATE_KEY]"
lient_email": "[CLIENT_EMAIL]",
lient_id": "[CLIENT_ID]",
uth_uri": "https://accounts.google.com/o/oauth2/auth",
oken_uri": "https://accounts.google.com/o/oauth2/token",
uth_provider_x509_cert_url": "[CERT_URL]",
lient_x509_cert_url": "[CLIENT_CERT_URL]"

Configure the Script

Open up tutorial.js and update the config object for your Google Cloud Platform configuration:

config = {
gcpProjectId: '[YOUR PROJECT ID]',
gcpPubSubSubscriptionName: '[YOUR PUB/SUB SUBSCRIPTION NAME]',
gcpServiceAccountKeyFilePath: './gcp_private_key.json'

Running the application

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.