import msal import os from msal import PublicClientApplication APPLICATION_ID_KEY = os.getenv('APPLICATION_ID_KEY ') CLIENT_SECRET_KEY = os.getenv('CLIENT_SECRET_KEY ') authority_url = 'https://login.microsoftonline.com/consumers' base_url = 'https://graph.microsoft.com/v1.0/' endpoint = base_url + 'me' SCOPES = ['User.Read','User.Export.All'] # Authenticate with Auth Code client_instance = msal.ConfidentialClientApplication( client_id=APPLICATION_ID_KEY, client_credential=CLIENT_SECRET_KEY, authority=authority_url ) authorization_request_url = client_instance.get_authorization_request_url(SCOPES) st.write('Connecting to MSGraph with url:' + authorization_request_url) webbrowser.open(authorization_request_url, new=True)