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

Token caching with custom profiles #105

Open
sbalian opened this issue May 9, 2019 · 1 comment
Open

Token caching with custom profiles #105

sbalian opened this issue May 9, 2019 · 1 comment

Comments

@sbalian
Copy link
Contributor

sbalian commented May 9, 2019

Token caching is implemented in faculty.session.get_session. But this calls faculty.config.resolve_profile which has a pre-defined order of places it pulls credentials from. It would be better if faculty.session.get_session takes in a faculty.config.Profile instance (or caching is implemented without having to always force resolving profiles). For example, on a platform server that has environmental variables defined, passing credentials_path to faculty.session.get_session has no effect.

Note that for my example there is a somewhat ugly workaround:

import faculty
import faculty.session
import faculty.clients

profile = faculty.config.load_profile('/path/to/config', 'default')
session = faculty.session.get_session(
    domain=profile.domain, client_id=profile.client_id,
    client_secret=profile.client_secret
)
client_class = faculty.clients.for_resource('cluster')
cluster = client_class(session)
@acroz
Copy link
Member

acroz commented Mar 6, 2020

Yeah, this is probably a better interface, as it allows more flexibility in constructing a session for a profile. I like the decoupling of loading profile from building the session. This would be an API-breaking change, which I feel is probably ok here as this interface is not frequently used.

Any thoughts @zblz @mociarain @imrehg?

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

No branches or pull requests

2 participants