Reputation: 2337
I read the documentation of google earth engine. And I also see the github repo of the Earthengine api. I am exactly following the documentation. In my project file I added config.py
file with my service account id
and the privatekey.json
file. I already write the following code and run it through terminal.
import ee
service_account = '<my-service-account-id>@tekson.iam.gserviceaccount.com'
credentials = ee.ServiceAccountCredentials(service_account, 'privatekey.json')
ee.Initialize(credentials)
But it doesn't get initialized the earthengine. It always shows the following error.
Traceback (most recent call last):
File "/home/tekson/gee/lib/python3.6/site-packages/ee/data.py", line 338, in _execute_cloud_call
return call.execute(num_retries=num_retries)
File "/home/tekson/gee/lib/python3.6/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "/home/tekson/gee/lib/python3.6/site-packages/googleapiclient/http.py", line 856, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/algorithms?prettyPrint=false&alt=json returned "Permission denied.">
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "config.py", line 4, in <module>
ee.Initialize(credentials)
File "/home/tekson/gee/lib/python3.6/site-packages/ee/__init__.py", line 123, in Initialize
ApiFunction.initialize()
File "/home/tekson/gee/lib/python3.6/site-packages/ee/apifunction.py", line 154, in initialize
signatures = data.getAlgorithms()
File "/home/tekson/gee/lib/python3.6/site-packages/ee/data.py", line 969, in getAlgorithms
return _cloud_api_utils.convert_algorithms(_execute_cloud_call(call))
File "/home/tekson/gee/lib/python3.6/site-packages/ee/data.py", line 340, in _execute_cloud_call
raise _translate_cloud_exception(e)
ee.ee_exception.EEException: Permission denied.
I don't understand how to use google service account. I also want to develop this app in Django later. Please anyone help me how can I fix this?
Upvotes: 2
Views: 2135
Reputation: 21
If ee.Authenticate() works but ee.Initialize() gives you a permission denied error, it might be because you have a tracking blocker addon installed on chrome. Ghostery and EFF Privacy Badger are ones that have given me this error. After I turned them off, no error.
Upvotes: 2
Reputation: 388
Your service account needs to be verified by Google to use service account. Alternatively, for development purpose locally just use ee.Authenticate()
to authenticate your GEE account and ee.Initialize()
to initialize it.
Upvotes: 1