You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] acquire_token_silent_with_error returns None with WSL broker #809
The initial acquire_token_interactive with organizations can return the access token as expected. However, when calling acquire_token_silent_with_error with a tenant ID, including home tenant (Microsoft tenant 72f988bf-86f1-41af-91ab-2d7cd011db47), the result is None.
Expected behavior acquire_token_silent_with_error should work with a tenant ID.
What you see instead acquire_token_silent_with_error returns None.
The MSAL Python version you are using
Latest dev branch.
Additional context
Add any other context about the problem here.
Jiashuo Li (@jiasli), this issue is likely because the keyring is not unlocked due to which msal is unable to fetch the token from the keyring.
Identity Auth stack on Linux relies on Keyring/secret service APIs as a secure storage for managing user authentication artifacts. On WLS, Keyring needs to be unlocked by the user before we can access it.
These are the instructions on how to unlock keyring on headless devices:
a. Start a D-Bus session, e.g. run dbus-run-session -- sh and run the following commands inside that shell.
b. Run gnome-keyring-daemon with --unlock option. Unlock options reads a password from stdin, and use it to unlock the login keyring or create it if the login keyring does not exist.
When that command is started, enter a password into stdin and press Ctrl+D (end of data). After that, the daemon will fork into the background (use --foreground option to block).
For a complete set of instructions see: [Using Keyring on headless Linux systems](https://github.com/jaraco/keyring#using-keyring-on-headless-linux-systems)
So for an application running in WSL to interact with MSAL and access the keyring, you must run the application within the same session where the GNOME Keyring Daemon is unlocked. Keyring access will only work if the application runs inside that session.
This is a known limitation with WSL, and we are working with them to make this seamless for the calling apps.
Activity
rayluo commentedon Apr 15, 2025
CC Xiang Yan (@xiangyan99) for awareness
DharshanBJ commentedon Apr 15, 2025
Jiashuo Li (@jiasli), this issue is likely because the keyring is not unlocked due to which msal is unable to fetch the token from the keyring.
Identity Auth stack on Linux relies on Keyring/secret service APIs as a secure storage for managing user authentication artifacts. On WLS, Keyring needs to be unlocked by the user before we can access it.
These are the instructions on how to unlock keyring on headless devices:
a. Start a D-Bus session, e.g. run dbus-run-session -- sh and run the following commands inside that shell.
b. Run gnome-keyring-daemon with --unlock option. Unlock options reads a password from stdin, and use it to unlock the login keyring or create it if the login keyring does not exist.
When that command is started, enter a password into stdin and press Ctrl+D (end of data). After that, the daemon will fork into the background (use --foreground option to block).
So for an application running in WSL to interact with MSAL and access the keyring, you must run the application within the same session where the GNOME Keyring Daemon is unlocked. Keyring access will only work if the application runs inside that session.
This is a known limitation with WSL, and we are working with them to make this seamless for the calling apps.
jiasli commentedon Apr 16, 2025
dbus-run-session -- shdoesn't seem to work well with Python's virtual virtual environment and shows gibberish:But luckily this doesn't affect command execution. It is also normal without a virtual environment.
jiasli commentedon Apr 16, 2025
gnome-keyring-daemonis not installed on WSL by default and requires manual installation:After running
then
broker starts to work.
I noticed I need to press Ctrl+D twice. This is also mentioned by
and explained by
For
acquire_token_silent_with_error, instead of returningNone, it should tell the user the requiredgnome-keyring-daemonis missing.There should be document clearly describing the prerequisites to use broker on WSL, instead of letting users to troubleshoot by themselves. The document should also describe how to reset the keyring if the password is forgotten, such as https://askubuntu.com/questions/65281/how-to-recover-reset-forgotten-gnome-keyring-password
DharshanBJ commentedon Jun 18, 2025
We have updated the documention that explains the steps to unlock the keyring - https://learn.microsoft.com/en-us/entra/msal/python/advanced/linux-broker-py-wsl?tabs=ubuntudep
Users can use Seahorse (a GNOME application for managing encryption keys and passwords) to manage the keyring contents through a Graphical User Interface (GUI) which gives a better UX.