Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save the project ID somewhere #315

Open
2 tasks
12rambau opened this issue Oct 7, 2024 · 0 comments
Open
2 tasks

save the project ID somewhere #315

12rambau opened this issue Oct 7, 2024 · 0 comments
Labels
kind: enhancement New feature or request

Comments

@12rambau
Copy link
Member

12rambau commented Oct 7, 2024

the project Id is the key to many functionalities of geetools and unfortunately there is an inconsistance in how this information get treated from GEE side itself (see https://issuetracker.google.com/issues/325020447 for more context).

When GEE is Initializedusing a personnal account I can get back the project_id information using the following:

import ee 

ee.initialize(project="ee-borntobealive")
project_id = ee.data._cloud_api_user_project

But this operation is not possible using a private key as shown in this example:

import ee
import os
import json
import tempfile
from pathlib import Path
import httplib2

# extract the environment variables data
private_key = os.environ["EARTHENGINE_SERVICE_ACCOUNT"]
ee_user = json.loads(private_key)["client_email"]

# connect to GEE using a temp file to avoid writing the key to disk
with tempfile.TemporaryDirectory() as temp_dir:
    file = Path(temp_dir) / "private_key.json"
    file.write_text(private_key)
    credentials = ee.ServiceAccountCredentials(ee_user, str(file))
    ee.Initialize(credentials=credentials, http_transport=httplib2.Http())
project_id = ee.data._cloud_api_user_project
  • The extention init method should save this information in a meaningful place
  • the Asset object shoud be able to rely on it to access current project_id
@12rambau 12rambau added the kind: enhancement New feature or request label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant