【问题标题】:Azure Data Factory - Trouble authenticating invalid_grantAzure 数据工厂 - 验证 invalid_grant 时遇到问题
【发布时间】:2019-03-22 05:03:48
【问题描述】:

在尝试通过 Active Directory 进行身份验证以检索访问令牌时,我执行了以下步骤:

1 - 使用以下说明在 Azure 中创建了一个应用程序(步骤 3): https://github.com/Azure-Samples/active-directory-java-native-headless#step-3--register-the-sample-with-your-azure-active-directory-tenant

2 - 创建了一个具有“数据工厂参与者”权限的“Azure Active Directory”用户帐户。

3 - 使用(以下网址)中的步骤,我按照示例代码尝试检索访问令牌: https://github.com/Azure-Samples/active-directory-java-native-headless/blob/master/src/main/java/PublicClient.java

注意:我使用的资源是... https://management.core.windows.net/

... 使用以下示例: https://docs.microsoft.com/en-us/azure/data-factory/quickstart-create-data-factory-rest-api#authenticate-with-azure-ad

4 - 服务器响应以下错误:

Exception in thread "main" java.util.concurrent.ExecutionException:
com.microsoft.aad.adal4j.AuthenticationException:
 {
    "error_description": "AADSTS65001: The user or administrator has not
    consented to use the application with ID '<my-app-id>' named
    '<my-app-name>'. Send an interactive authorization request for this
    user and resource.\r\nTrace ID: d0af56e6-aaa3-4d25-b23b-
    2984ed2b4400\r\nCorrelation ID: 2422cc2f-1cdd-45c5-8b7c-
    46b1eee4ffae\r\nTimestamp: 2019-03-22 04:58:16Z",

    "error": "invalid_grant"
 }

需要哪些授权才能使身份验证正常工作?

【问题讨论】:

  • 我的回答解决了你的问题吗?
  • 是的! :-) 再次感谢您抽出宝贵时间回复。

标签: java azure azure-active-directory azure-data-factory azure-data-factory-2


【解决方案1】:

您应该向 Azure AD 发出包含参数 prompt=admin_consent 的授权请求。

转到一个 URL,例如 https://login.microsoftonline.com/tenant-id/oauth2/authorize?client_id=app-client-id&redirect_uri=encoded-reply-url&response_type=code&prompt=admin_consent

使用您的管理员帐户同意权限。

那么我们就可以成功获取访问令牌了。

【讨论】:

  • 托尼 - 谢谢,这个建议帮助解决了我遇到的问题。非常感谢您的帮助。一切顺利。
  • @user3906977 :) 很高兴听到这个消息。你能把它作为答案吗?它可能会帮助其他人。谢谢。
  • @user3906977 要将答案标记为已接受,请单击答案旁边的复选标记以将其从灰色切换为已填充。
  • 完成!再次感谢...非常感谢。
猜你喜欢
  • 2015-12-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多