diff --git a/config/README.md b/config/README.md index b307eb1..8d6a4d2 100644 --- a/config/README.md +++ b/config/README.md @@ -15,7 +15,7 @@ Getting started 1. [Add Firebase to your Android Project](https://firebase.google.com/docs/android/setup). 2. Create a service account as described in [Adding Firebase to your Server](https://firebase.google.com/docs/admin/setup) and download the JSON file. - - Copy the private key JSON file to this folder and rename it to `service-account.json`. + - Set `GOOGLE_APPLICATION_CREDENTIALS` environment variable to path of downloaded credential file. 3. Change the `PROJECT_ID` variable in `configure.py` to your project ID. Run diff --git a/config/configure.py b/config/configure.py index 8a56f87..57faf35 100644 --- a/config/configure.py +++ b/config/configure.py @@ -15,10 +15,13 @@ def _get_access_token(): """Retrieve a valid access token that can be used to authorize requests. + This method must be called in either a trusted Google environment like GCP or if running + elsewhere the GOOGLE_APPLICATION_CREDENTIALS environment variable must be set to the path + of the service account credentials file. + :return: Access token. """ - credentials = ServiceAccountCredentials.from_json_keyfile_name( - 'service-account.json', SCOPES) + credentials = ServiceAccountCredentials.get_application_default().create_scoped(scopes=SCOPES) access_token_info = credentials.get_access_token() return access_token_info.access_token # [END retrieve_access_token]