I have a fully functional endpoint that will receive a POST request from a PubSub subscription when a change has been detected in a user's Gmail inbox. Inside of the endpoint, I can successfully extract everything I need for my purposes.
The problem is that I have no idea who is actually hitting my endpoint. A bad actor could just pass me the same payload that Gmail would.
Is there a way for me to verify that the payload that I'm receiving is actually from Google/Gmail/PubSub?
On the Gmail side: It seems the payload that is sent to my endpoint is unable to be changed and will always be of the form as detailed here: https://developers.google.com/gmail/api/guides/push
On the PubSub side: You can create your own topic and add key/value pairs as custom attributes to it, but it seems I wouldn't be able to modify the payload that Gmail is publishing to my topic. https://cloud.google.com/pubsub/docs/publisher
Any insight would be greatly appreciated thank you!