Geographic Information Systems Asked on January 8, 2021
I am using the Python API of Google Earth Engine and I authenticated myself a long time ago with :
import ee
ee.Authenticate()
I can now connect myself directly using ee.Initialize()
My question is how to revoke this authentification process ?
I am building a test suits for my librairy.
instead of using ee.Initialize() in the files that requires GEE API I created a function that check if the credential exists in the system (because of course they are unavailable in travis) to use a json private key file if necessary:
def init_ee():
"""Initialize earth engine according to the environment"""
# only do the initialization if the credential are missing
if not ee.data._credentials:
# if in test env use the private key
if 'EE_PRIVATE_KEY' in os.environ:
# key need to be decoded in a file
content = base64.b64decode(os.environ['EE_PRIVATE_KEY']).decode()
with open('ee_private_key.json', 'w') as f:
f.write(content)
# connection to the service account
service_account = '[email protected]'
credentials = ee.ServiceAccountCredentials(service_account, 'ee_private_key.json')
ee.Initialize(credentials)
# if in local env use the local user credential
else:
ee.Initialize()
return 0
I would like to launch my test suit in the same condition as in travis without pushing to github
Credentials are cached in something like ~/.config/earthengine/credentials
Removing that file should de-authenticate you
Correct answer by Pierrick Rambaud on January 8, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP