1

I'm working on a Flask app which is hosted on an Ubuntu 16.04 server running Apache. The app utilizes Google Earth Engine (GEE).

GEE stores tokens in and loads tokens from ~/.config/earthengine/credentials by default. While this does not pose any problems when making python -c calls to GEE, GEE fails to access the token from within Flask and, thereby, fails to run.

That is, when called within my Flask app, GEE raises an exception. I've traced this exception back through my apache error_log, and I believe this is the root of the problem:

[wsgi:error] tokens = json.load(open(oauth.get_credentials_path())
[wsgi:error] FileNotFoundError: [Errno 2] No such file or directory: 
   'var/www/.config/earthengine/credentials'

I've tried slightly changing the default credentials file path in earthengine/oauth.py to '. /.config/earthengine/credentials'. After doing so, I was still able to make python -c calls to GEE, but I had no luck with Flask.

I've considered just making some kind of folder specifically for using GEE within the context of my Flask app and, then, pointing earthengine/oauth.py to it. However, I am very wary of doing so.

At this point, I have no idea whether this is a Flask issue, an Ubuntu issue, a WSGI issue or something else entirely, so any suggestions would help.

Generally speaking, there are two questions which I feel should help get me closer to a solution: (1) how can I permit an oauth script access to ~/.config on Ubuntu? and (2) how can I properly point apache to ~/.config as the home directory, i.e., which .conf file should I be modifying to try and resolve this issue?


Edit: Having read up on some mod-wsgi issues, I think there might be chance that this has something to do with WSGIPassAuthorization. If so, what exactly should I do?

Update: I've changed the file permissions as suggested here, and I've changed the the file pointed to by oauth.py to '/root/.config/earthengine/credentials'. The good news: I am no longer getting an error with regards to accessing the file. The bad news: I am now getting an error resulting from an ostensibly bad refresh token. I've seen that this kind of thing could be a clock issue, but my clock looks alright to me:

  Local time: Sun 2019-05-26 17:11:12 UTC
  Universal time: Sun 2019-05-26 17:11:12 UTC
  RTC time: Sun 2019-05-26 17:11:12
  Time zone: Etc/UTC (UTC, +0000)
  Network time on: yes
  NTP synchronized: yes
  RTC in local TZ: no

(The clock looks fine when I look at ntpd -c lpeer output as well.)

In this light, I might note that when I earthengine authenticate the token value in my credentials file doesn't change. This does not seem to be hampering my local use of earthengine, but use within Flask is still an issue.

Update: I now believe this is the result of attempting to make calls without a Google Service Account.

LIAM M
  • 23
  • 4

1 Answers1

0

I have this identical issue. I do have a working google service account. This was confirmed by google. Additionally, everything works fine when I run the flask app locally. It only has problems seeing the privatekey.json when I start the flask app via apache server.

Justin G
  • 21
  • 3