0

Giving Azure ADAL for Python a try. Getting this error when import adal.

import adal

Gives error

token_response = adal.acquire_token_with_username_password( 
    AttributeError: 'module' object has no attribute 'acquire_token_with_username_password'

I have downloaded most recent code from Github.

The README has sample code that uses acquire_token_with_username_password so it should be present.

What am I missing?

import adal
token_response = adal.acquire_token_with_username_password(
    'https://login.windows.net/ACTIVE_DIRECTORY_TENANT.onmicrosoft.com',
    'username@ACTIVE_DIRECTORY_TENANT.onmicrosoft.com',
    'password'
)
Peter Pan
  • 23,476
  • 4
  • 25
  • 43
curtisp
  • 2,227
  • 3
  • 30
  • 62

2 Answers2

1

Got it sorted.

I had created a python file named adal.py that I was using to test adal.

Looks like adal module was looking at this file as application file?

After I renamed adal.py to adal_test.py it and delete its adal.pyc file now adal is working as expected.

curtisp
  • 2,227
  • 3
  • 30
  • 62
1

According to your description and answer, I think the issue was caused by name clashes. Your old script name adal was clashed with the directory name of the package adal for Python.

It's very similar with the other SO thread ImportError: cannot import name Session, when using Azure SDK, please see my answer for it.

Community
  • 1
  • 1
Peter Pan
  • 23,476
  • 4
  • 25
  • 43