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

Viewed 646

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.

1 Answers
Related