I’m building a REST API backend that fetches authenticated URLs for map tiles from private image asset collections in Google Earth Engine (GEE). Each user of the API has a unique Google Service Account (SA) linked to their requests. The backend uses these SA credentials to authenticate and execute operations through the GEE Python API.
The challenge is that the GEE Python API requires global initialization using the credentials, which creates problems for Isolation – Ensuring that one user’s credentials and operations are not accessible to other concurrent requests.
My Approach and Concerns
One approach I’ve considered is spawning a new process for each request and initializing the GEE API with the specific user’s service account credentials in that process. However initializing a new GEE instance for each request introduces overhead, especially under high traffic.
What I’m Looking For
Ideally, I want to:
- Authenticate each user’s service account once to receive a token.
- Use that token to securely execute GEE operations without re-initializing the API globally for every request.
Is there a way to securely initialize the GEE API per user without global state?