Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Add CredentialsCache classes #4

Merged
merged 1 commit into from
Oct 12, 2018
Merged

Conversation

tswast
Copy link
Collaborator

@tswast tswast commented Sep 14, 2018

The CredentialsCache classes allow for more flexible caching of user
credentials to disk. The pydata_google_auth.cache module provides 3
canonical instances of caches:

  • pydata_google_auth.cache.READ_WRITE : (default) read and write to a file in ~/.config/..., just like pandas-gbq does by default,
  • pydata_google_auth.cache.REAUTH : write to disk but don't read from it, just like pandas-gbq with reauth=True,
  • pydata_google_auth.cache.NOOP : don't read/write to disk at all. Useful when running on shared machines.

I believe this is the final implementation detail needed before releasing 0.1.0 of pydata-google-auth. The public interface includes:

  • pydata_google_auth.default(scopes, client_id=(pydata-auth project), client_secret=(pydata-auth project), credentials_cache=READ_WRITE, auth_local_webserver=False) : Same as current pandas-gbq behavior. Does google.auth.default() with fallback to user authentication.
  • pydata_google_auth.get_user_credentials(scopes, client_id=(pydata-auth project), client_secret=(pydata-auth project), credentials_cache=READ_WRITE, auth_local_webserver=False) : Get user credentials (loaded from cache, if available) via the 3-legged-oauth flow.

I'll update the docs to remove leftovers from the pandas-gbq fork in a subsequent PR.

Towards pandas-gbq auth rewrite: googleapis/python-bigquery-pandas#161

Closes #1

@craigcitro please review

The CredentialsCache classes allow for more flexible caching of user
credentials to disk. The pydata_google_auth.cache module provides 3
canonical instances of caches: NOOP (don't read/write to disk at all)
REAUTH (write to disk, but don't read), and READ_WRITE (the default).
@tswast
Copy link
Collaborator Author

tswast commented Sep 14, 2018

I haven't fully configured Travis yet. Tests pass locally.

$ pytest tests
============================== test session starts ===============================
platform darwin -- Python 3.6.4, pytest-3.7.1, py-1.5.4, pluggy-0.7.1
rootdir: /Users/swast/src/pydata-google-auth, inifile:
collected 7 items

tests/system/test_auth.py .....                                            [ 71%]
tests/unit/test_auth.py ..                                                 [100%]

=========================== 7 passed in 12.66 seconds ============================

@tswast tswast merged commit 0f46db8 into pydata:master Oct 12, 2018
@max-sixty
Copy link
Collaborator

When do you think we should move pandas-gbq to be dependent on this?

@tswast
Copy link
Collaborator Author

tswast commented Oct 12, 2018

I need to make a release of this package first. :-) I think it's "code complete", but I'm working on getting docs to build, tests running, etc.

@max-sixty
Copy link
Collaborator

OK great! This is going to be v useful, and I'm happy it can spread wider than pandas-gbq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants