Note: The push endpoints don't work with the App Engine's local devserver. The push notifications will go to an HTTP URL on the App Engine server even when you run this sample locally. So we recommend you deploy and run the app on App Engine.
-
Go to Google Developers Console and create a new project. This will automatically enable an App Engine application with the same ID as the project.
-
Enable the "Google Cloud Pub/Sub" API under "APIs & auth > APIs."
-
For local development also follow the instructions below.
-
Go to "Credentials" and create a new Service Account.
-
Select "Generate new JSON key", then download a new JSON file.
-
Set the following environment variable.
GOOGLE_APPLICATION_CREDENTIALS: the file path to the downloaded JSON file.
-
-
Install Python-2.7, pip-6.0.0 or higher and App Engine Python SDK. We recommend you install Cloud SDK rather than just installing App Engine SDK.
-
Install Google API client library for python into 'lib' directory by:
$ pip install -t lib -r requirements.txt
- Edit constants.py
- Replace '{AN_UNIQUE_TOKEN}' with an arbitrary secret string of your choice to protect the endpoint from abuse.
$ appcfg.py --oauth2 update -A your-application-id .
or you can use gcloud preview feature
$ gcloud preview app deploy --project your-application-id .
Then access the following URL: https://{your-application-id}.appspot.com/
$ dev_appserver.py -A your-application-id .