Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions config/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the google-auth library here. oauth2client is no longer maintained.

access_token_info = credentials.get_access_token()
return access_token_info.access_token
# [END retrieve_access_token]
Expand Down