question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ClientSecretCredential.get_token() fails in case of azurestack if we provide 'authority' URL

See original GitHub issue
  • Package Name: azure-identity:
  • Package Version: 1.6.1:
  • Operating System: ubuntu20.04:
  • Python Version: 3.8.10:

Describe the bug To authenticate python SDK to azure Stack hub we use ClientSecretCredential method and pass required parameters like ClientSecretCredential( tenant_id=tenantid, client_id=clientid, client_secret=secretkey, cloud_environment=cloud, authority=auth_resource).

when user pass authority url ‘https://management.private_domain.onmicrosoft.com/<b9ae38c5-####>’ parameter expilicitly the ClientSecretCredential.get_token() method throwing an error instead of successful response. ClientSecretCredential.get_token failed: Authentication failed: invalid_instance: The authority you provided, https://management.private_domain.onmicrosoft.com/<b9ae38c5-####>/<ed83b0eb-tenant_id>, is not whitelisted. If it is indeed your legit customized domain name, you can turn off this check by passing in validate_authority=False.

looks like the azure sdk explicitly appending tenant_id to the authority URL.

**msal_credentials.py**
def _create_app(self, cls, **kwargs):
        # type: (Type[msal.ClientApplication], **Any) -> msal.ClientApplication
        app = cls(
            client_id=self._client_id,
            client_credential=self._client_credential,
            **authority="{}/{}".format(self._authority, self._tenant_id)**,

can you please provide us more information about the change and how user can pass the authority URL. if we dont pass ‘authority URL’ then its working but with authority URL it fails.

To Reproduce Steps to reproduce the behavior:

  1. try to provide authority url along with other required parameters while creating ClientSecretCredential.

Expected behavior ClientSecretCredential.get_token() should work if user pass the authority URL.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
xiangyan99commented, Jan 26, 2022

@rayluo Thanks for the information. Unfortunately, we don’t have validate_authority support yet.

I created PR #22786 to support it.

0reactions
xiangyan99commented, Mar 8, 2022

@anotherancientalien could you share your error log?

Read more comments on GitHub >

github_iconTop Results From Across the Web

DefaultAzureCredential().GetTokenAsync fails when using ...
In Azure, I get this exception: Azure.Identity.AuthenticationFailedException: DefaultAzureCredential failed to retrieve a token from the ...
Read more >
Azure Identity client library for JavaScript | Microsoft Learn
The Azure Identity library provides Azure Active Directory (Azure AD) token authentication through a set of convenient TokenCredential ...
Read more >
Error Adding Azure Stack Client to Commvault | Community
Im getting this error when i try to add a new azure stack hub cleint ... Failed to get AzureStack URLs, Please make...
Read more >
DefaultAzureCredential: Unifying How We Get Azure AD Token
Azure Identity library provides Azure Active Directory token authentication support across the Azure SDK.
Read more >
azidentity - Go Packages
The Azure Identity module provides Azure Active Directory (Azure AD) token authentication support across the Azure SDK.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found