【问题标题】:Azure ADAL for Python - model has no attribute 'acquire_token_with_username_password'适用于 Python 的 Azure ADAL - 模型没有属性“acquire_token_with_username_password”
【发布时间】:2016-06-20 15:58:17
【问题描述】:

试试Azure ADAL for Python。导入 adal 时出现此错误。

import adal

报错

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

我从 Github 下载了最新的代码。

README 包含使用 acquire_token_with_username_password 的示例代码,因此它应该存在。

我错过了什么?

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'
)

【问题讨论】:

    标签: python python-2.7 azure azure-active-directory adal


    【解决方案1】:

    根据您的描述和回答,我认为问题是由名称冲突引起的。您的旧脚本名称 adal 与 Python 包的目录名称 adal 冲突。

    和另一个SO线程ImportError: cannot import name Session, when using Azure SDK非常相似,请看我的回答。

    【讨论】:

      【解决方案2】:

      整理好了。

      我创建了一个名为adal.py 的python 文件,用于测试adal。

      看起来 adal 模块正在将此文件视为应用程序文件?

      在我将 adal.py 重命名为 adal_test.py 并删除其 adal.pyc 文件后,现在 adal 可以正常工作了。

      【讨论】:

      • 很简单,还是错过了。感谢您分享这个答案。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-24
      • 1970-01-01
      • 2015-10-17
      • 1970-01-01
      • 2017-02-10
      相关资源
      最近更新 更多