Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: ee Authenticate method is deprecated and blocking requests #211

Closed
6 tasks done
2320sharon opened this issue Jan 10, 2024 · 4 comments
Closed
6 tasks done

Bug: ee Authenticate method is deprecated and blocking requests #211

2320sharon opened this issue Jan 10, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@2320sharon
Copy link
Collaborator

2320sharon commented Jan 10, 2024

Tools like Geemap have run into the same issue as we have that Google is deprecating how their 0Auth method works. Apartently a project id now needs to be manually entered into the ee.Initialize(project='my-project-id') as discovered by giswqs.

Tasks

  • Understand the deprecation
  • Figure out how to fix it
  • Figure out a long term fix
  • Update the instructions to authenticate if necessary
  • Update the authentication gif if necessary
  • implement this fix in all notebooks

Related Issues

gee-community/geemap#1870

Resources

Screenshots

Screenshot 2024-01-10 085656

image (8)

@2320sharon 2320sharon self-assigned this Jan 10, 2024
@2320sharon 2320sharon added the bug Something isn't working label Jan 10, 2024
@2320sharon
Copy link
Collaborator Author

The paragraph below explains how the new method of authentication works.

New Authentication Method with GEE

Source: https://developers.google.com/earth-engine/guides/auth

Python and Command Line
Prior to using the Earth Engine Python client library, you need to authenticate (verify your identity) and use the resultant credentials to initialize the Python client. The authentication flows use Cloud Projects to authenticate, and they're used for unpaid (free, noncommercial) use as well as paid use. To authenticate and initialize, run

ee.Authenticate()
ee.Initialize(project='my-project')

This will first select the best authentication mode for your environment, and prompt you to confirm access for your scripts. If credentials already exist, they are automatically reused - run ee.Authenticate(force=True) to create new credentials.

The initialization step verifies that valid credentials exist, either created from ee.Authenticate() or pre-existing as Google default credentials. It then initializes the Python client library with methods that the backend server supports. You will need to provide a project that you own, or have permissions to use, that also has the Earth Engine API enabled. This project will be used for running all Earth Engine operations.

On the command line, the equivalent call is earthengine authenticate. Provide a project for further calls using earthengine set_project {my-project}. Command line invocations will initialize automatically as needed.

@2320sharon
Copy link
Collaborator Author

CoastSeg only runs on the user's local computer, which means we can use auth_mode='localhost'. The authmode='localhost' can only be run on local computers and is actually much simpler to use than the old default method that was previously used to authenticate.

Solution

import ee
from google.auth import exceptions as google_auth_exceptions

ee.Authenticate(auth_mode='localhost')
ee.Initialize()

@2320sharon
Copy link
Collaborator Author

Updated the instructions in the coastsat notebook

image

@2320sharon
Copy link
Collaborator Author

  • Created a new gif you can see it here https://github.com/Doodleverse/CoastSeg/blob/main/docs/gifs/tutorial_for_authenticate_new.gif
    and it has been embeded directly into the SDS_coastsat_classifier.ipynb in v1.1.25.
  • I also updated the instructions in SDS_coastsat_classifier.ipynb in v1.1.25.
  • I created a new function in common.py called initialize_gee that initializes and authenticates with GEE. A call to this function has replaced the old code block in SDS_coastsat_classifier.ipynb that authenticates with GEE
    tutorial_for_authenticate_new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant