Skip to content

DefaultAzureCredential prints libsecret errors in linux container from SharedTokenCacheCredential #19857

@xinyi-joffre

Description

@xinyi-joffre
  • Package Name: azure.identity
  • Package Version: 1.6.0
  • Operating System: Linux debian (the python:3.7-slim-buster image)
  • Python Version: 3.7

Describe the bug
When using DefaultAzureCredential() in a jupyter notebook in a linux docker container, it dumps either pyobject or libsecret errors from the SharedTokenCacheCredential, which is confusing to users

To Reproduce
Steps to reproduce the behavior:

  1. docker run -it python:3.7-slim-buster /bin/bash
  2. run:
    > apt install libgirepository1.0-dev libcairo2-dev python3-dev gir1.2-secret-1
    > pip install pygobject
    > pip install azure-identity
    > python
    > from azure.identity import DefaultAzureCredential
    > DefaultAzureCredential().get_token("https://quantum.microsoft.com/.default")
  3. See libsecret errors when trying SharedTokenCacheCredential:
libsecret did not perform properly.
* If you encountered error "Remote error from secret service:
  org.freedesktop.DBus.Error.ServiceUnknown",
  you may need to install gnome-keyring package.
* Headless mode (such as in an ssh session) is not supported.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/msal_extensions/libsecret.py", line 126, in trial_run
    agent.save(payload)  # It would fail when running inside an SSH session
  File "/usr/local/lib/python3.7/site-packages/msal_extensions/libsecret.py", line 103, in save
    data, None)
gi.repository.GLib.GError: g-io-error-quark: Cannot autolaunch D-Bus without X11 $DISPLAY (0)
libsecret did not perform properly.
* If you encountered error "Remote error from secret service:
  org.freedesktop.DBus.Error.ServiceUnknown",
  you may need to install gnome-keyring package.
* Headless mode (such as in an ssh session) is not supported.

Expected behavior
DefaultAzureCredential should hide or suppress libsecret errors for SharedTokenCacheCredential.

It also looks like DotNet Azure.Identity excludes SharedTokenCacheCredential by default. For consistency across SDKs, it would also be great if azure-sdk-for-python similarly excluded SharedTokenCacheCredential from DefaultAzureCredential, since it really only works on Windows, and seems to cause issues on other systems.

For consistency, can the azure-identity package also set exclude_shared_token_cache_credential=True by default?

Merged PR for azure-sdk-for-net to remove SharedTokenCacheCredential from default: Azure/azure-sdk-for-net#16615
Related Issue: Azure/azure-sdk-for-net#17052

Screenshots
Lib Secret Errors in Notebooks Environment

Metadata

Metadata

Assignees

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.feature-requestThis issue requires a new behavior in the product in order be resolved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions