Cutomize OIDCAuth to get userinfo

This commit is contained in:
George 2024-10-04 16:30:26 -07:00
parent f6d2373f39
commit 862cccac7b

View File

@ -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",