Skip to content

Commit

Permalink
Merge pull request #30 from wri/gee-revert-auth-to-json-file
Browse files Browse the repository at this point in the history
Gee auth using json file instead of env vars
  • Loading branch information
yellowcap authored Nov 29, 2024
2 parents f636bda + a8aa220 commit 0b92853
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
6 changes: 1 addition & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ ANTHROPIC_API_KEY=<anthropic-api-key>
LANGFUSE_SECRET_KEY=<langfuse-secret-key>
LANGFUSE_PUBLIC_KEY=<langfuse-public-key>
LANGFUSE_HOST=http://localhost:3000
GEE_PROJECT_ID=<gee-proj-id>
GEE_PRIVATE_KEY_ID=<gee-private-key-id>
GEE_PRIVATE_KEY=<gee-private-key>
GEE_CLIENT_EMAIL=<gee-client-email>
GEE_CLIENT_ID=<gee-client-id>
GEE_SERVICE_ACCOUNT_PATH="ee-zeno-service-account.json"
18 changes: 2 additions & 16 deletions zeno/tools/distalert/gee.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,13 @@
def init_gee() -> None:
"""Initialize and authenticate gee"""

service_account_info = {
"type": "service_account",
"project_id": os.environ.get("GEE_PROJECT_ID"),
"private_key_id": os.environ.get("GEE_PRIVATE_KEY_ID"),
"private_key": os.environ.get("GEE_PRIVATE_KEY"),
"client_email": os.environ.get("GEE_CLIENT_EMAIL"),
"client_id": os.environ.get("GEE_CLIENT_ID"),
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": os.environ.get("GEE_CLIENT_CERT_URL"),
"universe_domain": "googleapis.com",
}

scopes = [
"https://www.googleapis.com/auth/earthengine",
"https://www.googleapis.com/auth/cloud-platform",
]

credentials = Credentials.from_service_account_info(
service_account_info, scopes=scopes
credentials = Credentials.from_service_account_file(
os.environ.get("GEE_SERVICE_ACCOUNT_PATH"), scopes=scopes
)

ee.Initialize(credentials)

0 comments on commit 0b92853

Please sign in to comment.