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.

how to specify `scopes` and retrieve TokenCredential

See original GitHub issue

Hi team, I’m trying to migrate our service from using deprecated msrestazure to Azure-identity. I’m trying to figure out how to use the scopes parameter in the Credential. For example, I’m trying to use azure-identity for getting secrets from azure keyvault:

credentials = DefaultAzureCredential(scopes=‘https://vault.azure.net’) secret_client = SecretClient(vault_url=vault_base_url, credential=credential)

but it didn’t work It looks like the scopes parameter is only used by the get_token() method but it returns AccessToken class instead, which is not what I want.

In the previous library it provides a parameter resource to specify what resource we are pointing to. https://github.com/Azure/msrestazure-for-python/blob/698eb06bcbf9fda4c7ae04d929f7b5b955fcbfed/msrestazure/azure_active_directory.py#L567 Do you know how I can get a TokenCredential class and specify the scopes?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jwxdcommented, Mar 21, 2022

Just a quick update, we tried to use the default scope and it works in both Public and Special clouds.

1reaction
jwxdcommented, Mar 3, 2022

Sure, I’m working on an internal build to test with my new fix without explicitly specifying scopes. I will keep you posted.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TokenCredential Class (Azure.Core) - Microsoft Learn
Gets an AccessToken for the specified set of scopes. SharedTokenCacheCredential Class (Azure.Identity) - Azure for .NET Developers. Authenticates using tokens ...
Read more >
python 3.x - How to properly use "get_token" of ...
Try to set scope as {your-api-client-id}/.default to get access token. Replace your-api-client-id with the client id/application id for your ...
Read more >
DefaultAzureCredential: Unifying How We Get Azure AD Token
It provides a set of TokenCredential implementations which can be used to construct Azure SDK clients which support AAD token authentication ...
Read more >
Checking if an access token has particular scopes
The resource server sends only the access token to /auth/introspection API, to get “a list of scopes associated with the token” and determine...
Read more >
azure.identity package — Azure SDK for Python 2.0.0 ... - NET
scopes (str) – desired scopes for the access token. Return type ... TokenCredential ) – credential instances to form the chain. get_token (*scopes...
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