AzureAD / microsoft-authentication-library-for-python

Microsoft Authentication Library (MSAL) for Python makes it easy to authenticate to Microsoft Entra ID. General docs are available here https://learn.microsoft.com/entra/msal/python/ Stable APIs are documented here https://msal-python.readthedocs.io. Questions can be asked on www.stackoverflow.com with tag "msal" + "python".
https://stackoverflow.com/questions/tagged/azure-ad-msal+python
Other
757 stars 192 forks source link

Close localhost tab automatically #524

Closed Abdurahman-hassan closed 1 year ago

Abdurahman-hassan commented 1 year ago

Hello,

After I set http://localhost in the active directory and use the acquire_token_interactive function to fetch the token

The content of redirection after successful authentication: Authentication completed. You can close this window now.

how I can close the localhost tab automatically http://localhost:5001/?code=0.ATAXXXXXX&session_state=8beXXXXXX

Is there a way to automate this process

I'm using msal for python

rayluo commented 1 year ago

It is unlikely that the tab can be automatically closed. In practice, it may not be desirable anyway, because a user usually already has a browser window with multiple tabs, your automatic closing the sign-in tab would probably end up with the user looking at an irrelevant preexisting tab.

You may, however, use an undocumented behavior of MSAL Python to supply a success_template="<html><body>Hooray, you have signed in! Now you may want to read <a href="http://example.com">our documentation page</a></body></html>". One of MSAL Python's downstream application, the Azure CLI, has a creative usage which can automatically redirect end user to the documentation page after 10 seconds.

Abdurahman-hassan commented 1 year ago

Thank you,

I have added this and it works for me success_template=""" """