Skip to content

Commit

Permalink
feat: Add authentication cell
Browse files Browse the repository at this point in the history
  • Loading branch information
dfguerrerom committed Dec 20, 2023
1 parent f8cab3f commit 92e5c64
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ui.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "6f434bc9",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"from pathlib import Path\n",
"import ee\n",
"\n",
"\n",
"def authenticate_gee():\n",
" \"\"\"Authenticate GEE using the credentials file in the user's home directory.\"\"\"\n",
" credential_folder_path = Path.home() / \".config\" / \"earthengine\"\n",
" credential_file_path = credential_folder_path / \"credentials\"\n",
" credentials = json.loads(credential_file_path.read_text())\n",
" project = credentials.get(\"project_id\", credentials.get(\"project\", None))\n",
" ee.Initialize(project=project)\n",
" assert ee.data.getAssetRoots(), \"Error: You have not initialized the GEE home folder. Please follow the the SEPAL documentation: https://docs.sepal.io/en/latest/setup/gee.html#initialize-the-home-folder.\"\n",
" \n",
"authenticate_gee()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 92e5c64

Please sign in to comment.