The frontend of my web app uses an access token (periodically generated by the backend) to issue requests to GCP text-to-speech. Issuing requests from the frontend rather than from the backend is essential to keep down both the costs of my service and the delays experienced by the user.
A not-well-intending user might use my app to synthesize speech for a short text, open the Network tab of the browser tools, and get the access token from the request headers sent by my frontend to GCP. He could thereafter use this access token to synthesize speech for a large corpus of text, with no way for me to catch him. How can I change the way I use access tokens to prevent this kind of fraudulent use?
Here are some directions I have thought about, but am not sure what is supported by GCP or whether there is an even better approach:
Create a separate API key for each user of my app and generate access token for the specific user. Then, even if a user uses his token outside of my app, GCP would have a record of the requests made by that user and I could request that record using the API to charge him.
Make access tokens single-use. This way, even if the user obtains the access token as it is being sent as part of a request, he will not be able to use it for another request.