cirro.sdk.login
1from cirro.auth import DeviceCodeAuth 2from cirro.cirro_client import CirroApi 3from cirro.config import AppConfig 4from cirro.sdk.portal import DataPortal 5 6 7class DataPortalLogin: 8 """ 9 Start the login process, obtaining the authorization message from Cirro 10 needed to confirm the user identity. 11 12 Useful when you need to authenticate a user in a non-blocking way. 13 14 Usage: 15 16 ```python 17 # Replace app.cirro.bio as appropriate 18 login = DataPortalLogin(base_url="app.cirro.bio") 19 20 # Present the user with the authorization message 21 print(login.auth_message) 22 23 # Generate the authenticated DataPortal object, 24 # blocking until the user completes the login process in their browser 25 portal = login.await_completion() 26 ``` 27 """ 28 base_url: str 29 auth_info: DeviceCodeAuth 30 31 def __init__(self, base_url: str = None, enable_cache=False): 32 app_config = AppConfig(base_url=base_url) 33 34 self.base_url = base_url 35 36 self.auth_info = DeviceCodeAuth( 37 region=app_config.region, 38 client_id=app_config.client_id, 39 auth_endpoint=app_config.auth_endpoint, 40 enable_cache=enable_cache, 41 await_completion=False 42 ) 43 44 @property 45 def auth_message(self) -> str: 46 """Authorization message provided by Cirro.""" 47 return self.auth_info.auth_message 48 49 @property 50 def auth_message_markdown(self) -> str: 51 """Authorization message provided by Cirro (Markdown format).""" 52 return self.auth_info.auth_message_markdown 53 54 def await_completion(self) -> DataPortal: 55 """Complete the login process and return an authenticated client""" 56 57 # Block until the user completes the login flow 58 self.auth_info.await_completion() 59 60 # Set up the client object 61 cirro_client = CirroApi( 62 auth_info=self.auth_info, 63 base_url=self.base_url 64 ) 65 66 # Return the Data Portal object 67 return DataPortal(client=cirro_client)
class
DataPortalLogin:
8class DataPortalLogin: 9 """ 10 Start the login process, obtaining the authorization message from Cirro 11 needed to confirm the user identity. 12 13 Useful when you need to authenticate a user in a non-blocking way. 14 15 Usage: 16 17 ```python 18 # Replace app.cirro.bio as appropriate 19 login = DataPortalLogin(base_url="app.cirro.bio") 20 21 # Present the user with the authorization message 22 print(login.auth_message) 23 24 # Generate the authenticated DataPortal object, 25 # blocking until the user completes the login process in their browser 26 portal = login.await_completion() 27 ``` 28 """ 29 base_url: str 30 auth_info: DeviceCodeAuth 31 32 def __init__(self, base_url: str = None, enable_cache=False): 33 app_config = AppConfig(base_url=base_url) 34 35 self.base_url = base_url 36 37 self.auth_info = DeviceCodeAuth( 38 region=app_config.region, 39 client_id=app_config.client_id, 40 auth_endpoint=app_config.auth_endpoint, 41 enable_cache=enable_cache, 42 await_completion=False 43 ) 44 45 @property 46 def auth_message(self) -> str: 47 """Authorization message provided by Cirro.""" 48 return self.auth_info.auth_message 49 50 @property 51 def auth_message_markdown(self) -> str: 52 """Authorization message provided by Cirro (Markdown format).""" 53 return self.auth_info.auth_message_markdown 54 55 def await_completion(self) -> DataPortal: 56 """Complete the login process and return an authenticated client""" 57 58 # Block until the user completes the login flow 59 self.auth_info.await_completion() 60 61 # Set up the client object 62 cirro_client = CirroApi( 63 auth_info=self.auth_info, 64 base_url=self.base_url 65 ) 66 67 # Return the Data Portal object 68 return DataPortal(client=cirro_client)
Start the login process, obtaining the authorization message from Cirro needed to confirm the user identity.
Useful when you need to authenticate a user in a non-blocking way.
Usage:
# Replace app.cirro.bio as appropriate
login = DataPortalLogin(base_url="app.cirro.bio")
# Present the user with the authorization message
print(login.auth_message)
# Generate the authenticated DataPortal object,
# blocking until the user completes the login process in their browser
portal = login.await_completion()
DataPortalLogin(base_url: str = None, enable_cache=False)
32 def __init__(self, base_url: str = None, enable_cache=False): 33 app_config = AppConfig(base_url=base_url) 34 35 self.base_url = base_url 36 37 self.auth_info = DeviceCodeAuth( 38 region=app_config.region, 39 client_id=app_config.client_id, 40 auth_endpoint=app_config.auth_endpoint, 41 enable_cache=enable_cache, 42 await_completion=False 43 )
auth_info: cirro.auth.DeviceCodeAuth
auth_message: str
45 @property 46 def auth_message(self) -> str: 47 """Authorization message provided by Cirro.""" 48 return self.auth_info.auth_message
Authorization message provided by Cirro.
auth_message_markdown: str
50 @property 51 def auth_message_markdown(self) -> str: 52 """Authorization message provided by Cirro (Markdown format).""" 53 return self.auth_info.auth_message_markdown
Authorization message provided by Cirro (Markdown format).
55 def await_completion(self) -> DataPortal: 56 """Complete the login process and return an authenticated client""" 57 58 # Block until the user completes the login flow 59 self.auth_info.await_completion() 60 61 # Set up the client object 62 cirro_client = CirroApi( 63 auth_info=self.auth_info, 64 base_url=self.base_url 65 ) 66 67 # Return the Data Portal object 68 return DataPortal(client=cirro_client)
Complete the login process and return an authenticated client