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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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 .
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
git clone https://github.com/spark/google-cloud-datastore-tutorial.git
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]"
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'
gcpProjectId
: Your Google Cloud Platform Project IDgcpPubSubSubscriptionName
: Your Google Cloud Platform Pub/Sub topic's subscription namenpm install
node tutorial.js