scitacean.auth.OAuthClientDevice#
- class scitacean.auth.OAuthClientDevice(*, provider, client_id, local_timeout=datetime.timedelta(seconds=60), remote_timeout=datetime.timedelta(seconds=5), scopes=('openid',), extra_request_parameters=None, allow_http=False)[source]#
An OAuth client for ‘device’ authentication flows.
This client implements the ‘device’ flow of OAuth. It runs an interactive login flow via the user’s web browser and a device code. The browser can be opened on any machine as long as the user enters the correct device code. This client is therefore usable on systems without a GUI and on remote Jupyter instances.
See also
Constructors
__init__(*, provider, client_id[, ...])Create a new client.
Methods
login([open_browser])Log in with the IdP.
Attributes
The timeout for calls to the identity provider.
- __init__(*, provider, client_id, local_timeout=datetime.timedelta(seconds=60), remote_timeout=datetime.timedelta(seconds=5), scopes=('openid',), extra_request_parameters=None, allow_http=False)[source]#
Create a new client.
- Parameters:
provider (
str) – The URL of the OAuth provider.client_id (
str) – The client ID of the OAuth client.local_timeout (
timedelta, default:datetime.timedelta(seconds=60)) – Timeout for receiving a confirmation from the identity provider. The identity provider may shorten this time.remote_timeout (
timedelta, default:datetime.timedelta(seconds=5)) – Timeout for calls to the identity provider.scopes (
Iterable[str], default:('openid',)) – The scopes to request from the identity provider. Only change this if login fails with the default.extra_request_parameters (
dict[str,str] |None, default:None) – Parameters to add to URLs.allow_http (
bool, default:False) – Whether to allow the use of HTTP instead of HTTPS. Only use this for testing! Otherwise, secrets are transmitted unencrypted.
- login(open_browser=None)[source]#
Log in with the IdP.
This runs an interactive login flow via a web browser.
- Parameters:
open_browser (
Callable[[str],SupportsClose] |None, default:None) – A function that opens a given URL in the user’s web browser. By default, the client either uses the system’s default browser or, in Jupyter, opens a browser through JavaScript. The return value is intended to close the browser window or at least release any auxiliary resources.- Returns:
ExpiringToken– An IdP access token. (This is not a SciCat token.)