Skip to content

Commit

Permalink
Updated python notebooks with new GEE auth methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jamievleeshouwer committed Jun 5, 2024
1 parent adea00e commit 530d109
Show file tree
Hide file tree
Showing 4 changed files with 1,577 additions and 261 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,49 +37,28 @@
},
"source": [
"## Authenticate and initialize\n",
"Run the `ee.Authenticate()` function to authenticate your access to Earth Engine servers and `ee.Initialize()` to initialize it. Upon running the following cell you'll be asked to grant Earth Engine access to your Google account. **Follow the instructions printed to the cell.**\n",
"\n",
"Whilst following the prompts, you will need to ensure:\n",
"\n",
"- Use read-only scopes: **Unchecked** \n",
"- All access options presented: **Checked** "
"Run the `ee.Authenticate()` function to authenticate your access to Earth Engine servers and `ee.Initialize()` to initialize it. Upon running the following cell you'll be asked to grant Earth Engine access to your Google account. **Please follow the instructions in the prompts.** You will also need to enter your Google Earth Engine Cloud Project ID below."
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "0E7Roy_8vEMr",
"outputId": "ffa97718-6494-499d-d7cf-c7cb46f64d1d"
"id": "0E7Roy_8vEMr"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"To authorize access needed by Earth Engine, open the following URL in a web browser and follow the instructions. If the web browser does not start automatically, please manually browse the URL below.\n",
"\n",
" https://accounts.google.com/o/oauth2/auth?client_id=517222506229-vsmmajv00ul0bs7p89v5m89qs8eb9359.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fearthengine+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdevstorage.full_control&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&code_challenge=MbiUX6k1PE3zV0XemXZTV5uwFkDgg4pLRfz_f0Zg8t8&code_challenge_method=S256\n",
"\n",
"The authorization workflow will generate a code, which you should paste in the box below. \n",
"Enter verification code: 4/1AX4XfWhu2C1NuqLJdn_knjKlSZm9gN4vEAUw9cQD1tHtvo1agRUkrrGRlrg\n",
"\n",
"Successfully saved authorization token.\n"
]
}
],
"outputs": [],
"source": [
"# Import the Earth Engine module\n",
"import ee\n",
"\n",
"# Cloud Project ID to associate with your Earth Engine workspace.\n",
"project = \"Your Project ID to use\"\n",
"\n",
"try:\n",
" ee.Initialize() # Initialize the library.\n",
" ee.Initialize(project=project) # Initialize the library.\n",
"except Exception as e:\n",
" ee.Authenticate() # If initialization fails, authentication is required... Trigger the authentication flow and initialize again.\n",
" ee.Initialize() # Initialize the library."
" ee.Initialize(project=project) # Initialize the library."
]
},
{
Expand All @@ -94,7 +73,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"id": "_WX90K5wAq32"
},
Expand All @@ -115,7 +94,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"id": "bOVj_wrStdP1"
},
Expand All @@ -140,7 +119,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"id": "vILLXX5tLLgc"
},
Expand All @@ -162,28 +141,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 533
},
"id": "WF45XxalDfM-",
"outputId": "52782af0-dee3-46d3-bfd8-32ac195fb8e7"
"outputId": "0d7ae709-9075-44c3-c166-e46c8f273fb4"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<img src=\"https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/3a243a71d0d6990a3cfe9edf544656f6-f76e56756a1618f9916d1ff79fc6e80e:getPixels\"/>"
"<img src=\"https://earthengine.googleapis.com/v1/projects/tern-landscapes/thumbnails/a1929835869f2a6f9f6646383a952790-5e0201962847eb9c32e39363700c8fd7:getPixels\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
"execution_count": 5
}
],
"source": [
Expand Down Expand Up @@ -211,7 +190,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"id": "5DjGDn-fbbLG"
},
Expand Down Expand Up @@ -250,20 +229,20 @@
"base_uri": "https://localhost:8080/"
},
"id": "GvV0RRGIFNZz",
"outputId": "5a04b001-5ff8-41f8-ec17-f8e3906e38cf"
"outputId": "d803250d-4b5e-4537-e305-0183d8579a61"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"name": "stdout",
"text": [
"[Task:RRZUALZSJLHYRQBTWIALZNWE] - State changed to READY\n",
"[Task:RRZUALZSJLHYRQBTWIALZNWE] - State changed to RUNNING\n"
"[Task:LWHTQYIWELNI75D5FIFRDGW6] - State changed to READY\n",
"[Task:LWHTQYIWELNI75D5FIFRDGW6] - State changed to RUNNING\n"
]
}
],
"source": [
"import time \n",
"import time\n",
"\n",
"# Function to report the status to the standard output.\n",
"status = {'state': None}\n",
Expand All @@ -283,7 +262,7 @@
"if 'destination_uris' in status: # Task completed\n",
" print('[Task:{0}] - Data location: {1}'.format(task.id, status['destination_uris']))\n",
"if 'error_message' in status: # Task failed\n",
" print('[Task:{0}] - Failed with error: {1}'.format(task.id, status['error_message'])) "
" print('[Task:{0}] - Failed with error: {1}'.format(task.id, status['error_message']))"
]
},
{
Expand All @@ -298,7 +277,6 @@
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "Example 1 - CMRSET Long-Term Average ET (Temporal Aggregation).ipynb",
"provenance": []
},
Expand All @@ -312,4 +290,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
Loading

0 comments on commit 530d109

Please sign in to comment.