From 862cccac7b31151dfc4c910483eff758fa9d2f05 Mon Sep 17 00:00:00 2001 From: Charlie Date: Fri, 4 Oct 2024 16:30:26 -0700 Subject: [PATCH] Cutomize OIDCAuth to get userinfo --- indicators.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/indicators.py b/indicators.py index b72daa4..af04292 100644 --- a/indicators.py +++ b/indicators.py @@ -561,6 +561,21 @@ def intelligent_loop_plots(sym, stk_data): # return True # return False +class OIDCAuthCustom(OIDCAuth): # overide OIDCAuth to get logged in user info + + def __init__(self, *args, **kwargs): + self.userinfo = None + super().__init__(*args, **kwargs) + + def callback(self, idp: str): + return_value = super().callback(idp) + + client = self.get_oauth_client(idp) + self.userinfo = client.userinfo() + # ... + + return return_value + # Initialize the app app = Dash(__name__) @@ -571,7 +586,10 @@ app = Dash(__name__) # secret_key="MK8dyS6PyDDuEuzrmqa7dJTJZ7eH2Jkh", # ) -auth = OIDCAuth(app, secret_key=os.environ['SECRET_KEY']) +# auth = OIDCAuth(app, secret_key=os.environ['SECRET_KEY']) + +auth = OIDCAuthCustom(app, secret_key=os.environ['SECRET_KEY']) + auth.register_provider( "stock", token_endpoint_auth_method="client_secret_post",