-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/add token options #41
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
base: feature/migrate_session_from_rc
Are you sure you want to change the base?
Feature/add token options #41
Conversation
|
When using external authentication, we should probably consider passing around the whole authentication payload and a timestamp of when authentication happened instead of just the token. Currently, when we use an external token getter, an EdFiClient has no way of knowing when the token expires or when to refresh it since we only pass it the token. Implementing an expiration-aware client would probably improve performance and avoid hammering the token getter. |
Description
Adds the option to pass in an existing OAuth access token when instantiating clients, either as a string or as a callable (which will be called repeatedly, on every call to
EdFiSession.authenticate). With new default limits for how many active tokens may exist at any time, this allows for easier sharing of tokens between processes.Breaking changes:
access_tokenis a named argument so existing calls using client key/secret as positional arguments should be unaffected.Changes to existing files:
edfi_client.py:access_tokennamed argument to init; checks that only one ofclient_secretoraccess_tokenare provided.refresh_buffer_secondsoptional argument; makes original 120-second buffer between expiry time and scheduled refresh configurable, as in the extras for an Airflow connection objectsession.py:access_token, if passed, into theexternal_access_tokeninstance variable on EdFiSession instantiationEdFiSession.authenticate, add a fork for getting external tokens instead of fetching oneEdFiSession._with_exponential_backoffif it's the last retryrefresh_buffer_secondsfrom caller; makes buffer time configurable but still defaults to 120s.New files created:
tests/test_external_tokens.py: Basic pytest tests for new functionality