Unconventional Wisdom
Unconventional Wisdom

Reputation: 331

How can I publish to Google Pub/Sub from frontend mobile clients?

Is it considered good practice to have my mobile clients publish messages directly to Pub/Sub?

I am looking to publish topics about user views, taps, and overall activity information directly into Pub/Sub. The volume of data inflow is quite large, so I don't want to use Cloud Functions (will overkill on no. of invocations) or Cloud Endpoints (will unnecessarily flood my logs with pretty granular activity data).

But I have been searching Google Cloud's documentation, and could not find any way to securely publish messages from frontend (web, mobile) clients. I can solve this by giving a simple service account key (that only has publishing roles), but that seems bad practice to embed account key json files into the client?

The answer to a similar question: Is it good practice to have a React Native app Publish directly to a Google Pub/Sub topic? suggested putting Pub/Sub behind Cloud Functions, which I feel would incur a lot of costs for the data I am piping through.

Upvotes: 2

Views: 1646

Answers (1)

Kir Titievsky
Kir Titievsky

Reputation: 361

This solution paper is a fairly comprehensive answer to your question. There are others of course.

https://cloud.google.com/solutions/setting-up-a-pubsub-proxy-for-mobile-clients-on-gke

Upvotes: 2

Related Questions