flood_marl / setup_auth.py
jonybepary's picture
Add files using upload-large-folder tool
8277b83 verified
import os
def setup_gee():
print("Setting up Google Earth Engine Authentication...")
try:
import ee
# Use auth_mode='notebook' and explicit scopes to avoid the blocked 'drive' scope
# This is the standard fix for 'This app is blocked' errors in Kaggle/Colab
ee.Authenticate(auth_mode='notebook', scopes=['https://www.googleapis.com/auth/earthengine', 'https://www.googleapis.com/auth/cloud-platform'])
ee.Initialize(project='bubbly-trail-458020-m2')
print("GEE Authenticated Successfully.")
except Exception as e:
print(f"GEE Authentication failed: {e}")
def check_cds():
print("Checking CDS API key ...")
cds_path = os.path.expanduser("~/.cdsapirc")
if os.path.exists(cds_path):
print("CDS API key found in ~/.cdsapirc.")
else:
print("CDS API key NOT found! Please set up ~/.cdsapirc with your API key.")
print("Format:")
print("url: https://ewds.climate.copernicus.eu/api")
print("key: <PERSONAL-ACCESS-TOKEN>")
if __name__ == "__main__":
setup_gee()
check_cds()