0

I have this code and I have written it in windows. and it works fine in windows but when I run it on Linux and I have to run it on Linux as of my project needs and it does not works there and gives me the following error

AttributeError: 'ServicePrincipalCredentials' object has no attribute 'get_token'

from azure.mgmt.security import SecurityCenter
from azure.common.credentials import ServicePrincipalCredentials
import Credentials
from pprint import pprint

client = SecurityCenter(Credentials.credential,Credentials.subscription_id,asc_location="")

for score in client.secure_scores.list():
   print(score)
Hassan Turi
  • 334
  • 3
  • 14
  • There's lots of results if you google that error, can you share what you've tried so we don't waste yours and our time by suggesting things you've already done? If you haven't yet searched for the error then please do that first. – Random Davis May 20 '22 at 16:03
  • I have searched and tried my best That's why I am asking here. why is it working on windows but not on Linux? the Libraries and their versions all are smae – Hassan Turi May 20 '22 at 16:13
  • So you tried running `pip install azure-identity` for instance? Have you ensured that you're running the exact same version of each library, and their dependencies, and the same version of Python, on both systems? – Random Davis May 20 '22 at 16:18
  • yes I have double-checked every library version 2 3 times – Hassan Turi May 20 '22 at 16:36
  • I have generated the `req.txt` file from windows and installed it in Linux. also compared every library with versions. – Hassan Turi May 20 '22 at 16:38

1 Answers1

2

Assuming you are using latest version of azure-mgmt-security, it works with azure-identity package.

e.g.instead of from azure.common.credentials import ServicePrincipalCredentials, you can use from azure.identity import ClientSecretCredential.

(I work in MS in the SDK team)

Xiang Yan
  • 194
  • 6