Google Cloud Pub/Sub, publishing with a HTTP PUSH request - google-cloud-pubsub

I am trying to use google clouds pub/sub feature to store incoming data from an IOT device. I have an event call back which should be sending a JSON string to the pub/sub topic, from the IOT device's back-end. The callback looks like this (where {project},{topic} and {YOUR_API_KEY} are filled in as required:
POST https://pubsub.googleapis.com/v1/projects/{project}/topics/{topic}:publish?key={YOUR_API_KEY}
{"messages":[{"data":"test"}]}
I am invariably getting error 403 with this set up. I have tried various slight variations on this and found other errors. I am very new to this topic, is there an obvious mistake I am making?

API Keys are not sufficient for authenticating to the Google Cloud Pub/Sub API. Only a subset of GCP services allow access using only an API key, as detailed in the Using API Keys documentation. You will need to use a service account to authenticate for using Cloud Pub/Sub. You might also want to consider Google Cloud IoT, which sends telemetry into Cloud Pub/Sub.

Related

What does Google mean with "Google APIs"? Is an App Engine endpoint (e.g. xxx.appspot.com) a Google API?

I have a couple of running Cloud functions that fetch data from an external API and then post the received data into an internal API which is running on Google App Engine. I've come up with this approach because the external API has a rate limit that I sometimes need to bypass.
In order to calculate the monthly cost of this setup I was looking at the Google Docs and saw this:
Outbound data to other Google APIs in the same region is free, as is inbound data. Where the Google API you are using is global (i.e. not region-specific), it is considered to be the same region.
My question: What does Google mean with "Google APIs"? Is an App Engine endpoint (e.g. xxx.appspot.com) a Google API?
Google APIs generally refer to the APIs and services provided as part of Google Cloud, as well as other Google services such as SMTP provided by Gmail and recaptcha.

Using AWS Lambda to watch SNS topic and deliver by websocket?

For testing/debugging purposes, I would create a web app that emulates the functionality of one of the 3rd party actors in our system. It should be able to publish and subscribe to messages sent on the AWS SNS service.
I was planning to make a ReactJS web app that calls an API made in AWS Lambda. Sending messages should be fine, with some buttons in the app, calling a Lambda that publishes SNS messages to a topic.
But what about monitoring the messages sent to the relevant topics that I want to watch? I was thinking about using a websocket that could receive messages. I know I can trigger a Lambda with SNS messages, but how do I make the lambda deliver these messages to the websocket? is that possible at all without having a permanent server session running? Should I combine with other things in the AWS toolbox?
When I originally wrote this answer websocket support for Lambda was not available, but it is now: https://aws.amazon.com/blogs/compute/announcing-websocket-apis-in-amazon-api-gateway/
I was also looking for exact same thing but unfortunately aws sns doesn't have websocket support.
But I came across a very interesting blog. So what he has done is using AWS IoT which supports websockets and pub-sub. You can take a look here
Edit :
AWS API Gateway gives the functionality to manage Websockets in serverless way. Here is a quick starter guide API Gateway Websockets

Google Cloud PubSub Accessing Query Parameters

I have a system that publishes messages to Cloud PubSub but the data of the message is passed as query parameters in a GET request (as opposed to using the body of POST request).
Does PubSub even accept HTTP GET requests as published messages?
Is there any way to access these query parameters using the Apache Beam
Java SDK?
With regard to the first question, the Google Cloud Pub/Sub REST API documentation states which kind of HTTP method is accepted for each of the API calls. Publish requires the POST method.

Google Cloud Datastore how to create, update and delete entity with http request

As Google Cloud Datastore client libraries are available for some language only. Now, How can do operation like create, update and delete of entity without using client libraries with HTTP request.
The Datastore API is built on HTTP and JSON, so any standard HTTP client can send requests to it and parse the responses.You can find more about building a flexible run time here
One of the classic way to do this is to expose the datastore CRUD operations through a set of REST APIs. Google offers Cloud Endpoints which are a set of "tools, libraries and capabilities that allow you to generate APIs and client libraries from an App Engine application" https://cloud.google.com/appengine/docs/java/endpoints/
You can have a look at this tutorial https://rominirani.com/google-cloud-endpoints-tutorial-part-1-b571ad6c7cd2#.1j9holpdt

Can I Use Google App Engine as XMPP Gateway

I have a Cloud App hosted on Windows Azure and I need to integrate XMPP with the service. Can I use GAE's XMPP API to achieve this? I'll need to be able to create new Jabber IDs and send & receive messages from other clients like GTalk.
As far as I know, GAE only supports Java, Python and my expertise is limited to .NET & C#; so, I'll have to make my Azure App to communicate with the GAE.
Finally, can I use GAE as an alternative to running ejabbered on Windows Azure Virtual Machines or Amazon EC2?
Thanks in advance... :)
You could but it would be very limited. You may be better off running ejabbered somewhere else.
With GAE's XMPP API, your username selection is rather limited. See the GAE XMPP Overview API documentation.
Your Cloud App would need to send and receive messages from your GAE app via HTTP accesses. This is no big deal for sending, but you'll have to work your own way of receiving messages. You could buffer your messages to the datstore and poll for messages. You could use the Channel API to receive messages directly, but so far the Channel API client is only available in Javascript, so your app would need some sort of javascript interpreter to use the client.
You will be able to send/receive messages from other XMPP addresses like GTalk clients.

Resources