Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
drf7 committed Aug 9, 2024
1 parent c5cd925 commit 424a99d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions nucliadb/src/nucliadb/writer/tus/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ async def get_access_headers(self):
return {"AUTHORIZATION": f"Bearer {token}"}

def _get_access_token(self):
if self._credentials.access_token_expired or self._credentials.invalid is True:
request = google.auth.transport.requests.Request()
self._credentials.refresh(request)
if isinstance(self._credentials, google.auth.compute_engine.credentials.Credentials):
# google default auth object
if self._credentials.expired or self._credentials.valid is False:
request = google.auth.transport.requests.Request()
self._credentials.refresh(request)

return self._credentials.token
return self._credentials.token
else:
access_token = self._credentials.get_access_token()
return access_token.access_token

async def finalize(self):
if self.session is not None:
Expand Down

0 comments on commit 424a99d

Please sign in to comment.