在天蓝色应用程序中允许database.windows.net范围的位置
尝试使用范围 windows.database.net/user_impersonation 获取 Azure SQL 数据库的访问令牌。
我正在将请求发送到 https://login.microsoftonline.com /{tenant_name}/oauth2/v2.0/token
当范围为 storage.azure.com/user_impersonation 时,请求成功运行。我认为这是因为我已在应用程序的 API 权限中授予了对此范围的访问权限。但是,当请求范围“https://database.windows.net/user_impersonation”时,响应为:AADSTS65001:用户或管理员尚未同意使用具有 ID 的应用程序,
除非我在 API 权限部分中找不到此权限我在 Azure 门户中的应用程序。我如何授予访问权限?
Trying to get an access token for Azure SQL Database using scope windows.database.net/user_impersonation.
I am sending the request to https://login.microsoftonline.com/{tenant_name}/oauth2/v2.0/token
The request is working successfully when the scope is storage.azure.com/user_impersonation. I think this is because I have granted access to this scope in the API permissions for my application. However, when requesting the scope 'https://database.windows.net/user_impersonation' the response is: AADSTS65001: The user or administrator has not consented to use the application with ID
Except I cannot find this permission in the API permissions section for my application in the Azure portal. How do I grant access?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢@Gaurav Mantri 提出的宝贵建议。将您的建议作为答案发布以帮助其他社区成员。
如果您在范围级别没有有效的 API 权限,通常会发生此错误。如果您尝试获取 Azure SQL 数据库的访问令牌,则必须启用以下范围的 API 权限:windows.database.net/user_impersonation。
要查找这些权限,请按照以下步骤操作:
转到Azure门户-> Azure AD ->应用程序注册 ->您的申请 -> API 权限
如果在这些 API 中找不到 Azure SQL 数据库,则必须公开该 API。
添加该权限后,您可以避免该错误并可以获得访问令牌。
如果您找不到这些 API 权限,请不要搜索“SQL”尝试“Azure SQL”,因为 Azure 门户仅支持开头为过滤器!
更详细的信息,请参考以下链接:
https://learn.microsoft.com/en-us/azure/azure-sql/database/active-directory-interactive-connect-azure-sql-db#configure-your-c-application-in-the -azure-portal
https://blog.hompus.nl/2017/03/25/missing-azure-apis-when-adding-permissions-to-an-azure-ad-app/
Thank you @Gaurav Mantri for your valuable suggestion. Posting your suggestion as an answer to help other community members.
This error usually occurs if you don’t have valid API permissions at scope level. If you are trying to get access token for Azure SQL Database, you must enable API permissions of scope: windows.database.net/user_impersonation.
To find those permissions, follow below steps:
Go to Azure Portal -> Azure AD -> App Registrations -> Your Application -> API Permissions
If you don’t find Azure SQL Database in those APIs, you must expose that API.
After adding that permission, you can avoid that error and can get access token.
If you cannot find those API permissions, instead of searching ‘SQL’ try “Azure SQL” as Azure Portal supports only Begins With filter!
For more in detail, please refer below links:
https://learn.microsoft.com/en-us/azure/azure-sql/database/active-directory-interactive-connect-azure-sql-db#configure-your-c-application-in-the-azure-portal
https://blog.hompus.nl/2017/03/25/missing-azure-apis-when-adding-permissions-to-an-azure-ad-app/