gee-community / qgis-earthengine-plugin

Integrates Google Earth Engine and QGIS using Python API
http://qgis-ee-plugin.appspot.com
MIT License
448 stars 115 forks source link

Authorisation issue? #116

Closed JRichetti closed 2 years ago

JRichetti commented 2 years ago

Hi QGIS EE team,

When I installed the plugin it did not requested anything. No pop-up asking to link my GEE account. When trying to check if everything is working I'm getting the following error:

import ee
print(ee.String('Hello World from EE!').getInfo())
Traceback (most recent call last):
  File "C:\PROGRA~1\QGIS32~1.8\apps\Python39\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\computedobject.py", line 32, in __call__
    return type.__call__(cls, *args, **kwargs)
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\ee_string.py", line 32, in __init__
    self.initialize()
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\ee_string.py", line 53, in initialize
    apifunction.ApiFunction.importApi(cls, 'String', 'String')
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\apifunction.py", line 183, in importApi
    cls.initialize()
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\apifunction.py", line 154, in initialize
    signatures = data.getAlgorithms()
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 1058, in getAlgorithms
    call = _get_cloud_api_resource().projects().algorithms().list(
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 282, in _get_cloud_api_resource
    raise ee_exception.EEException(
ee.ee_exception.EEException: Earth Engine client library not initialized. Run `ee.Initialize()`

Then when running 'ee.Initialize()' another error comes up:

ee.Initialize()
Traceback (most recent call last):
  File "C:\PROGRA~1\QGIS32~1.8\apps\Python39\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\__init__.py", line 128, in Initialize
    data.initialize(
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 201, in initialize
    _install_cloud_api_resource()
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 260, in _install_cloud_api_resource
    _cloud_api_resource = _cloud_api_utils.build_cloud_resource(
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\_cloud_api_utils.py", line 161, in build_cloud_resource
    resource = build()
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\_cloud_api_utils.py", line 141, in build
    return discovery.build(
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\googleapiclient\_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\googleapiclient\discovery.py", line 270, in build
    content = _retrieve_discovery_doc(
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\googleapiclient\discovery.py", line 376, in _retrieve_discovery_doc
    resp, content = req.execute(num_retries=num_retries)
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\googleapiclient\_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\googleapiclient\http.py", line 900, in execute
    resp, content = _retry_request(
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\googleapiclient\http.py", line 177, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\google_auth_httplib2.py", line 209, in request
    self.credentials.before_request(self._request, method, uri, request_headers)
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\google\auth\credentials.py", line 133, in before_request
    self.refresh(request)
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\google\oauth2\credentials.py", line 302, in refresh
    ) = reauth.refresh_grant(
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\google\oauth2\reauth.py", line 347, in refresh_grant
    _client._handle_error_response(response_data)
  File "C:\Users\***\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\google\oauth2\_client.py", line 62, in _handle_error_response
    raise exceptions.RefreshError(error_details, response_data)
google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})

Please help. :)

gena commented 2 years ago

I assume it's with v0.0.5?

What version of QGIS and OS?

Try to install the latest version of earthengine-api in your Python environment (not in QGIS!) and run:

earthengine authenticate
JRichetti commented 2 years ago

Ah! Good old internet person forgetting to provide full information on errors and expecting adequate responses! Nonetheless, thanks Gena, I was missing installing the earthengine-api in the Python bits. Now I'm getting a nice and clean Hello World!

import ee
print(ee.String('Hello World from EE!').getInfo())
Hello World from EE!