gee-community / ee-initialize-github-actions

Instructions for initializing to Earth Engine in Python scripts run with GitHub Actions
Apache License 2.0
5 stars 2 forks source link

Issue with Workload Identity Federation through a Service Account #6

Open thekester opened 3 weeks ago

thekester commented 3 weeks ago

Issue: Improvements Needed for Workload Identity Federation Tutorial (WIF) through a Service Account

Related Issue: gee-community/ee-initialize-github-actions#5

Hello there, I've been working on improving the tutorial for Workload Identity Federation (WIF) through a Service Account, as described here. I identified a few missing pieces in the tutorial that might be causing issues for other users as well, and I wanted to share my progress and some challenges I'm facing.

Improvements Made to Tutorial
Current Issue: Authentication Error

However, I'm currently facing an authentication issue when trying to initialize Earth Engine using the Python script.

The error I'm receiving is as follows:

ee.ee_exception.EEException: Please authorize access to your Earth Engine account by running earthengine authenticate

Here are the details of my last workflow failure: Workflow Run Log

I tried to automate the authentication process by adding the following to the Python script:

import ee
from google.oauth2 import service_account
import os

ee.Authenticate(quiet=True)

credentials_path = os.getenv('GOOGLE_APPLICATION_CREDENTIALS')
credentials = service_account.Credentials.from_service_account_file(credentials_path)
# Initialize Earth Engine with the credentials
ee.Initialize(credentials)

However, I got the following error indicating an issue with the credentials file format:

google.auth.exceptions.MalformedError: Service account info was not in the expected format, missing fields token_uri, client_email.

My question is how to solve the ee authentication issue in the python script?