From f1dd45d55b0f63bdcbff367176faa9a3696efd2a Mon Sep 17 00:00:00 2001
From: Raffaele Gaetano <raffaele.gaetano@cirad.fr>
Date: Thu, 12 Sep 2024 14:26:33 +0200
Subject: [PATCH] MOD: api_key no longer available in Planetary

---
 TimeSeries/s1planetary.py | 5 +++--
 Workflows/operations.py   | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/TimeSeries/s1planetary.py b/TimeSeries/s1planetary.py
index 28e04c2..010734f 100644
--- a/TimeSeries/s1planetary.py
+++ b/TimeSeries/s1planetary.py
@@ -11,9 +11,10 @@ import otbApplication as otb
 import json
 from Common.geotools import get_query_bbox
 
-def fetch(shp, dt, output_fld, api_key, direction=None):
+def fetch(shp, dt, output_fld, api_key=None, direction=None):
 
-    os.environ['PC_SDK_SUBSCRIPTION_KEY'] = api_key
+    if api_key is not None:
+        os.environ['PC_SDK_SUBSCRIPTION_KEY'] = api_key
     bbox, i_bbox, shp_srs = get_query_bbox(shp, return_all=True)
 
     api = Client.open('https://planetarycomputer.microsoft.com/api/stac/v1', modifier=PC.sign_inplace)
diff --git a/Workflows/operations.py b/Workflows/operations.py
index a861c2e..3117b65 100644
--- a/Workflows/operations.py
+++ b/Workflows/operations.py
@@ -106,8 +106,9 @@ def preprocess_s1(in_fld, roi, out_fld, dem_fld=None, geoid=None, direction=None
 
 def fetch(imagery, shp, out_fld, dt=None, auth=None, only_tiles=None):
     assert(imagery in ['s2theia', 's2planetary', 's1grd', 's1rtc', 'planetmosaics', 'cop-dem-glo-30', 'nasadem', 'landsatplanetary'])
-    if imagery not in ['s2planetary', 'cop-dem-glo-30', 'nasadem'] and auth is None:
-        raise ValueError("Please provide authentication information.")
+    # Seems that Planetary don't need api _keys anymore
+    #if imagery not in ['s2planetary', 'cop-dem-glo-30', 'nasadem'] and auth is None:
+    #    raise ValueError("Please provide authentication information.")
     if imagery not in ['cop-dem-glo-30', 'nasadem'] and dt is None:
         raise ValueError("Please provide date range option.")
     if imagery == 's2theia':
-- 
GitLab