Skip to content

Commit

Permalink
Merge pull request #118 from statisticsnorway/fix-credentials-gcs-fil…
Browse files Browse the repository at this point in the history
…e-system

Use 'Credentials' object instead of raw token in GCSFileSystem wrapper
  • Loading branch information
mallport authored Feb 2, 2024
2 parents 507b051 + 558e65f commit c6e5d69
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dapla-toolbelt"
version = "2.0.5"
version = "2.0.6"
description = "Dapla Toolbelt"
authors = ["Dapla Developers <[email protected]>"]
license = "MIT"
Expand Down
4 changes: 1 addition & 3 deletions src/dapla/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def get_gcs_file_system(**kwargs: Any) -> GCSFileSystem:
See https://gcsfs.readthedocs.io/en/latest for advanced usage
"""
return GCSFileSystem(
token=AuthClient.fetch_google_credentials().token, **kwargs
)
return GCSFileSystem(token=AuthClient.fetch_google_credentials(), **kwargs)

@staticmethod
def ls(gcs_path: str, detail: bool = False, **kwargs: Any) -> Any:
Expand Down
3 changes: 2 additions & 1 deletion src/dapla/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from typing import Optional

import gcsfs
from google.oauth2.credentials import Credentials


class GCSFileSystem(gcsfs.GCSFileSystem): # type: ignore [misc]
"""GCSFileSystem is a wrapper around gcsfs.GCSFileSystem."""

def __init__(
self, token: Optional[dict[str, str] | str] = None, **kwargs: Any
self, token: Optional[dict[str, str] | str | Credentials] = None, **kwargs: Any
) -> None:
"""Initialize GCSFileSystem."""
super().__init__(token=token, **kwargs)
Expand Down

0 comments on commit c6e5d69

Please sign in to comment.