You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a result of the way that _get_default_credentials_path works, when pydata-google-auth is imported it will error if the user's home directory is not writeable. As this happens on import there appears to be no way for the user to avoid this, even if they do not intend to use the library to write to disk (including not using any of the credentials caches).
This makes the library hard to use in restricted environments, including those which might not have accessible writeable space.
The easiest reproduction is to override $HOME to something non-writeable:
$ HOME=/root python -c 'import pydata_google_auth'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/peter/.virtualenvs/styleme/lib/python3.5/site-packages/pydata_google_auth/__init__.py", line 2, in <module>
from .auth import default
File "/home/peter/.virtualenvs/styleme/lib/python3.5/site-packages/pydata_google_auth/auth.py", line 16, in <module>
from pydata_google_auth import cache
File "/home/peter/.virtualenvs/styleme/lib/python3.5/site-packages/pydata_google_auth/cache.py", line 233, in <module>
READ_WRITE = ReadWriteCredentialsCache()
File "/home/peter/.virtualenvs/styleme/lib/python3.5/site-packages/pydata_google_auth/cache.py", line 165, in __init__
self._path = _get_default_credentials_path(_DIRNAME, _FILENAME)
File "/home/peter/.virtualenvs/styleme/lib/python3.5/site-packages/pydata_google_auth/cache.py", line 37, in _get_default_credentials_path
os.makedirs(config_path)
File "/home/peter/.virtualenvs/styleme/lib/python3.5/os.py", line 231, in makedirs
makedirs(head, mode, exist_ok)
File "/home/peter/.virtualenvs/styleme/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/root/.config'
Fixing #7 might help with this, though ideally it would be possible to use the library without it requiring disk access at all.
The text was updated successfully, but these errors were encountered:
Thanks for pointing this out! Yeah, that's definitely a bug that it fails at import time.
I do intend for this library to be useful without disk access. It should (but obviously doesn't right now) fail gracefully if it cannot write to the cache directory for credentials.
I think the fix we should do in this case is not have any side effects like creating a directory in _get_default_credentials_path. Instead, the directory should be created when the credentials are saved to disk.
Hi,
I'm using this library via https://github.com/pydata/pandas-gbq.
As a result of the way that
_get_default_credentials_path
works, when pydata-google-auth is imported it will error if the user's home directory is not writeable. As this happens on import there appears to be no way for the user to avoid this, even if they do not intend to use the library to write to disk (including not using any of the credentials caches).This makes the library hard to use in restricted environments, including those which might not have accessible writeable space.
The easiest reproduction is to override
$HOME
to something non-writeable:Fixing #7 might help with this, though ideally it would be possible to use the library without it requiring disk access at all.
The text was updated successfully, but these errors were encountered: