Skip to content

Commit 18f672a

Browse files
committed
Use default application credential
1 parent 688fcfa commit 18f672a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

config/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Getting started
1515

1616
1. [Add Firebase to your Android Project](https://firebase.google.com/docs/android/setup).
1717
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.
18-
- Copy the private key JSON file to this folder and rename it to `service-account.json`.
18+
- Set `GOOGLE_APPLICATION_CREDENTIALS` environment variable to path of downloaded credential file.
1919
3. Change the `PROJECT_ID` variable in `configure.py` to your project ID.
2020

2121
Run

config/configure.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
def _get_access_token():
1616
"""Retrieve a valid access token that can be used to authorize requests.
1717
18+
This method assumes it is either running in a trusted Google environment like GCP or if running
19+
elsewhere the the GOOGLE_APPLICATION_CREDENTIALS environment variable is set to the path of the
20+
service account credentials file.
21+
1822
:return: Access token.
1923
"""
20-
credentials = ServiceAccountCredentials.from_json_keyfile_name(
21-
'service-account.json', SCOPES)
24+
credentials = ServiceAccountCredentials.get_application_default().create_scoped(scopes=SCOPES)
2225
access_token_info = credentials.get_access_token()
2326
return access_token_info.access_token
2427
# [END retrieve_access_token]

0 commit comments

Comments
 (0)