0
votes

I use Google Analytics Reporting API V4 along with googleapiclient and oauth2client to pull data from google analytics to my flask app. I did this by creating a key new key in an existing service account. I then created a virtual environment and followed the documentation from here: https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-py. Note I included my client_secrets.json file in my src folder. Before deploying I included the necessary external libraries in the requirements.txt file (google-api-pyhton-client, oauth2client, httplib2, uritemplate), however received a 500 error, unlike what my local environment was producing where it is working fine.

It is also important to know that I have a build pipeline on bitbucket which deploys the web app. I did not make any changes to this yaml file. Any ideas on how to fix this issue?

EDIT: I included the following bash script in my pipeline.yaml file which still results in the same error

  • echo src/client_secrets.json
  • gcloud auth activate-service-account --key-file src/client_secrets.json
  • gcloud config set project
1
Check your logs in your cloud console to see what the error traceback is. - GAEfan
I checked the logs and the error is FileNotFoundError: [Errno 2] No such file or directory: '/srv/src/client_secrets.json'. But the file does exist in this location. The code I used to set the file location was KEY_FILE_LOCATION = os.path.abspath('src/client_secrets.json'). I've also tried doing just src/client_secrets.json but it returns the same error. Any thoughts? - tapish jain

1 Answers

1
votes

Here are the key items to check (from the tutorial):

Move the previously downloaded client_secrets.json within the same directory as the sample code.

Replace the values of the key_file_location with the appropriate values from the Developer Console. ( what does your dev console say?)

key_file_location = `<REPLACE_WITH_JSON_FILE_LOCATION>`
import logging
logging.debug(key_file_location)

Does this match the value from Dev Console?