Skip to content

Commit

Permalink
Do not require project if credentials are obtained from a service acc…
Browse files Browse the repository at this point in the history
…ount

PiperOrigin-RevId: 721481175
  • Loading branch information
Google Earth Engine Authors committed Jan 31, 2025
1 parent 3646b8a commit 5ecd61c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/ee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import re
from typing import Any, Hashable, List as ListType, Optional, Sequence, Tuple, Type, Union

from google.oauth2 import service_account

from ee import _utils
from ee import batch
from ee import data
Expand Down Expand Up @@ -189,7 +191,10 @@ def Initialize(
project = project or None
# A project must be given, but SDK projects are not authorized for EE.
is_valid_project = project and not oauth.is_sdk_project(project)
if not is_valid_project:
is_sa_creds = isinstance(credentials, service_account.Credentials)
# An explicit project is not required for service accounts, since they use
# their containing project by default.
if not is_valid_project and not is_sa_creds:
raise EEException(NO_PROJECT_EXCEPTION)

data.initialize(
Expand Down

0 comments on commit 5ecd61c

Please sign in to comment.