File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121 MissingStompConfigurationError ,
2222)
2323from blueapi .core .bluesky_types import DataEvent
24- from blueapi .service .authentication import SessionManager
24+ from blueapi .service .authentication import SessionCacheManager , SessionManager
2525from blueapi .service .model import (
2626 DeviceModel ,
2727 DeviceResponse ,
@@ -729,3 +729,18 @@ def get_python_env(
729729 """
730730
731731 return self ._rest .get_python_environment (name = name , source = source )
732+
733+ def login (self , token_path : Path | None = None ):
734+ try :
735+ auth : SessionManager = SessionManager .from_cache (token_path )
736+ access_token = auth .get_valid_access_token ()
737+ assert access_token
738+ print ("Logged in" )
739+ except Exception :
740+ if oidc := self .oidc_config :
741+ auth = SessionManager (
742+ oidc , cache_manager = SessionCacheManager (token_path )
743+ )
744+ auth .start_device_flow ()
745+ else :
746+ print ("Server is not configured to use authentication!" )
You can’t perform that action at this time.
0 commit comments