3
votes

I'm wondering how to use Service Account on Google App Engine standard environment. I wrote some codes like below to access BigQuery with a proper JSON key file.

from google.cloud import bigquery
....
bigquery_client = bigquery.Client.from_service_account_json(proper_path_to_json_key)
list(bigquery_client.list_datasets())

The code works OK when I run it on a local Python interpreter but results miserably failed with the following error when it runs on local dev_appserver.py.

TransportError: ('Connection aborted.', error(13, 'Permission denied'))

When it runs on GAE, it still fails but its error message is like below.

TransportError: ('Connection broken: IncompleteRead(208 bytes read)', IncompleteRead(208 bytes read))

I think this error is caused by GAE's restriction on outbound traffic described here https://cloud.google.com/appengine/docs/standard/python/issue-requests but I have no idea how to resolve it.

What is the best way to use Service Account on GAE environment?

1

1 Answers

0
votes

Unfortunately, App Engine Standard does not yet support Google Client Libraries such as the BigQuery library you are attempting to use, as stated in this GitHub topic, although it is work in progress.

Alternatively, you can rather try a deployment in App Engine Flexible if that fits your requirements, or try the Google API Client Libraries instead.

Regarding your question about using Service Accounts with App Engine, you can either use the default built-in service accounts available when running that service, or create custom ones. You can find more information about the usage of service accounts in App Engine Standard in the documentation.