管理员未同意使用该应用程序 -- Azure AD
administrator has not consented to use the application -- Azure AD
我正在尝试从 Python 客户端应用程序中获取来自 Azure AD 的令牌。我希望用户仅使用用户名和密码进行无缝身份验证(client_id / secret 将嵌入应用程序中)。我注册了我的应用程序并授予它所有权限,然后根据 post:
在新门户中点击 "grant permissions" 按钮
我正在发送一个 http post 到:
https://login.microsoftonline.com/{tenant_id}/oauth2/token
具有以下数据:
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
body = "resource={0}&grant_type=password&username={1}&password={2}&client_id={3}&client_secret={4}&scope=openid".format(app_id_uri,user,password,client_id,client_secret)
无论我尝试什么,我似乎都无法克服这个错误:
b'{"error":"invalid_grant","error_description":"AADSTS65001: The user or administrator has not consented to use the application with ID \'078c1175-e384-4ac7-9116-efbebda7ccc2\'. Send an interactive authorization request for this user and resource.
再一次,我的目标:
用户输入用户/密码,仅此而已。 App发送user/pass/client_id/client_secret,获取token。
您应该尝试以管理员身份登录,以便能够完全同意在您的租户上使用该应用程序。
根据您的评论:
The message I'm receiving says to do an interactive request but that is exactly what I'm trying to avoid because this is a python app with no web browser and I'm trying to avoid complexity.
我想你想构建一个守护程序应用程序或一个与 Azure AD 集成的纯应用程序。大致介绍可以参考https://graph.microsoft.io/en-us/docs/authorization/app_only。
此外,您可以利用 ADAL for Python to implement this functionality with a ease. Also, you can refer to client_credentials_sample.py 快速入门。
我正在尝试从 Python 客户端应用程序中获取来自 Azure AD 的令牌。我希望用户仅使用用户名和密码进行无缝身份验证(client_id / secret 将嵌入应用程序中)。我注册了我的应用程序并授予它所有权限,然后根据 post:
在新门户中点击 "grant permissions" 按钮我正在发送一个 http post 到:
https://login.microsoftonline.com/{tenant_id}/oauth2/token
具有以下数据:
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
body = "resource={0}&grant_type=password&username={1}&password={2}&client_id={3}&client_secret={4}&scope=openid".format(app_id_uri,user,password,client_id,client_secret)
无论我尝试什么,我似乎都无法克服这个错误:
b'{"error":"invalid_grant","error_description":"AADSTS65001: The user or administrator has not consented to use the application with ID \'078c1175-e384-4ac7-9116-efbebda7ccc2\'. Send an interactive authorization request for this user and resource.
再一次,我的目标:
用户输入用户/密码,仅此而已。 App发送user/pass/client_id/client_secret,获取token。
您应该尝试以管理员身份登录,以便能够完全同意在您的租户上使用该应用程序。
根据您的评论:
The message I'm receiving says to do an interactive request but that is exactly what I'm trying to avoid because this is a python app with no web browser and I'm trying to avoid complexity.
我想你想构建一个守护程序应用程序或一个与 Azure AD 集成的纯应用程序。大致介绍可以参考https://graph.microsoft.io/en-us/docs/authorization/app_only。
此外,您可以利用 ADAL for Python to implement this functionality with a ease. Also, you can refer to client_credentials_sample.py 快速入门。