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.

Unable to authenticate to Azure GraphRBAC using DefaultAzureCredential OR CredentialWrapper

See original GitHub issue
  • Package Name: azure-graphrbac
  • Package Version: 0.61.1
  • Operating System: Mac OS 10.14.6
  • Python Version: Python 3.7.6

Describe the bug We are unable to use the DefaultAzureCredential OR the CredentialWrapper class (cred_wrapper.py) to authenticate the graphrbac client to create an App, Service Principal, and secret key.

NOTE: I am able to get the API to work if i use UserPassCredentials instead.

To Reproduce Steps to reproduce the behavior:

  1. Log into azure using the azure cli locally.
  2. Run python, import azure-graphrbac, and then use DefaultAzureCredential or the CredentialWrapper class (cred_wrapper.py) to create a credential object with the currently-logged-in-user credentials.
  3. These credentials are valid to do other azure operations (for example creating a Blob storage container), but when used with graphrbac to create an App, it prints the following error:
azure.graphrbac.models.graph_error_py3.GraphErrorException: Access Token missing or malformed.

Expected behavior I expect the DefaultAzureCredential or the CredentialWrapper class (cred_wrapper.py) to return credentials that are valid for graphrbac.

Additional context In addition, this entire Python API is (admittedly newly) legacy and is being deprecated in favor of the Microsoft Graph API here https://docs.microsoft.com/en-us/graph/api/application-post-applications . However there does not seem to be a Python API client that allows us to use this new API yet…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
srusuncommented, Dec 31, 2020

Thanks @lmazeul for the response! Within the time we posted and the time of the response, there were many things we managed to figure out on our own (the resource_id, role definition PUT, etc…). However we believe there are still some key features missing from the Azure Python API that would have been very beneficial to our development process - specifically the following,

  1. A python client that can generate a client secret - Instead of going directly to a HTTP request)

  2. A python client for adding api permissions - Instead of going directly to a HTTP request)

  3. A python client to create an sp/app using the modern API - We were only able to create it using GraphRbacManagementClient which uses the legacy API

  4. Getting the tenant id of a logged in user (We currently shell out to az account show in python and parse the response)

1reaction
lmazuelcommented, Jan 4, 2021

Thanks for the clarification @srusun !

Microsoft Graph SDK is under development, I don’t have timeline yet (it’s actually not our team, since it’s not Azure specific). The best repo is indeed so far https://github.com/microsoftgraph/msgraph-sdk-python-core

For #15971 , I realized I misguided you, I was thinking you need that in azure-graphrbac, but you need that from the Microsoft Graph and we dont’ have it here. You might want to create your issue https://github.com/microsoftgraph/msgraph-sdk-python-core instead.

I’m keeping this issue opened as a placeholder of the question: should we re-release a version of azure-graphrbac that supports azure-identity, knowing that the endpoint is about to be deprecated finally and Microsoft Graph SDK is coming.

https://developer.microsoft.com/en-us/office/blogs/microsoft-graph-or-azure-ad-graph/

Read more comments on GitHub >

github_iconTop Results From Across the Web

DefaultAzureCredential Class (Azure.Identity) - Microsoft Learn
This example demonstrates authenticating the BlobClient from the Azure.Storage.Blobs client library using the DefaultAzureCredential, deployed to an Azure ...
Read more >
Getting error while trying to list users in active directory using ...
I got an error, that insufficient privileges as the GraphrbacManagementClient uses the Azure AD graph legacy API permissions to get the users ...
Read more >
python azure ad authentication
There are two main strategies for authenticating apps to Azure during local development: Use DefaultAzureCredential in an application To use ...
Read more >
Python 3.9.4 | Azure SDK 1.13.0 - Skillable
You can use the DefaultAzureCredential class to obtain credentials, ... Your scripts can communicate success or failure to Skillable Studio in one of...
Read more >
graphrbac - Go Packages
Package graphrbac implements the Azure ARM Graphrbac service API version 1.6. ... the application should expect in the authentication and access tokens.
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