Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Pub/Sub Publishing from Browser - How does Auth work?

I have a requirement to use Google Cloud Pub/Sub API directly from Browser ( similar to GA script). I was wondering how can in handle Auth without requiring going through a back-end server.

I want to invoke the Cloud Pub/Sub API directly from the browser. I tried and it says i need to authenticate first , my issue is how to secure the Auth Token.

Is there any javascript library that is available which i can use in Browser ( not backend) to invoke the Google Pub/Sub API.

Thanks in advance

like image 706
Sathish Senathi Avatar asked Mar 16 '15 21:03

Sathish Senathi


People also ask

How does Pubsub work in GCP?

Google Cloud Pub/Sub provides messaging between applications. Cloud Pub/Sub is designed to provide reliable, many-to-many, asynchronous messaging between applications. Publisher applications can send messages to a "topic" and other applications can subscribe to that topic to receive the messages.

Does Pub/Sub use HTTP?

The Pub/Sub server sends each message as an HTTPS request to the subscriber client at a pre-configured endpoint.

How does Pub/Sub deliver messages to endpoints?

The Pub/Sub service delivers messages to push endpoints from the same Google Cloud region that the Pub/Sub service stores the messages.


1 Answers

The general approach in Javascript for authorizing and making authorized requests to Google APIs is shown at https://developers.google.com/api-client-library/javascript/samples/samples#AuthorizingandMakingAuthorizedRequests -- it's not specific to the Cloud Pubsub API, but it should work for all Google APIs. Similarly, https://developers.google.com/api-client-library/javascript/start/start-js for general Javascript access to Google APIs.

like image 93
Alex Martelli Avatar answered Nov 12 '22 11:11

Alex Martelli