Flask on GAE - Connect to Google API - Can't use JSON file
<p>I'm fairly new to Flask, GAE and the use of API. I'm trying to build a basic Web App that can connect to one of Google's API.</p>

<p>My folder structure looks like this (I've kept it to the main files):<br>
app-webemotions:<br>
-app.yaml<br>
-main.py<br>
-lib<br>
--sentimentanalysis.py<br>
-static<br>
--credential.json</p>

<p>Everything is working but providing the json file for the credentials. My understanding is that there's a couple of ways to do it:<br>
1) Setting up the GOOGLE_APPLICATION_CREDENTIALS environment variable to the destination of my file in app.yaml<br>
2) Requesting the file through my script (sentimentanalysis.py)  </p>

<p>Unfortunately, I haven't been able to make any of those work.  </p>

<p><strong>Option 1):</strong><br>
In app.yaml I have the line:</p>

<pre><code>env_variables:
   GOOGLE_APPLICATION_CREDENTIALS: static/key/credentials.json
</code></pre>

<p>I then run my code through dev_appserver.py . and get the following error:  </p>

<pre><code>ApplicationDefaultCredentialsError: File static/key/credentials.json (pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!
</code></pre>

<p><strong>Option 2):</strong>
I have a line of code in my script sentimentanalysis.py:</p>

<pre><code>  scope = ['https://www.googleapis.com/auth/cloud-platform']
  credentials = ServiceAccountCredentials.from_json_keyfile_name('/static/credentials.json', scope)
</code></pre>

<p>And when running the code I get the following error:</p>

<pre><code>    raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/static/credentials.json'
INFO     2016-08-06 04:10:51,678 module.py:788] default: "POST /Sentiment-analysis HTTP/1.1" 500 -
</code></pre>

<p><strong>Question:</strong><br>
So it looks like regardless of the method I'm using, I'm not able to provide the right path to the JSON file</p>

<p>My question is to know first if any of the above options is the right option and if yes, what am I doing wrong? If they are not the right options, what would you recommend?</p>

<p>Apologies if this has already been asked, I've tried to find an answer for a few hours now and haven't been able to crack it...</p>

<p>Thank you!</p>