What is the recommended approach for reusing of the same REST API third-party service across multipl

Hello,

I'd love to know what are some best practices for reusing third-party APIs on Google Cloud. Do I have to manually fetch access token, cache it and make the actual request to the REST API every time? Are there any better approaches / google cloud services to set up an integration of some sort with that external service?

As an example, imagine a Cloud Function that fetches a list of customers from the third-party API, so it first fetches the access token and then gathers the Customer data using that access token. Then, there's the other Cloud Function which uses the same exact API (following the similiar logic) but for a different purpose, for example to calculate a new balance on customer's bank account after a recent transaction.

So far I've been fetching an access token for each function manually (if the last access token has expired) using a library and then caching the new token. It works but I believe it could've been further improved, perhaps utilizing some of the available Google Cloud Services(?)

I'd love to hear if there's a better way of reusing the same external REST API across multiple Cloud Functions?

Kind regards

0 0 26