【问题标题】:ADAL 4 Android not passing client secretADAL 4 Android 未传递客户端机密
【发布时间】:2014-10-09 12:33:47
【问题描述】:

我首先要说的是,我敢肯定只有我自己,因为人们可能已经开箱即用,无需编辑 ADAL 4 Android 库而不编辑源代码。

在运行示例程序并使用令牌进行身份验证时,我从 AZURE 收到一个错误,即它没有在消息正文中传递 client_secret。我可以确认情况确实如此 - 它没有传递 client_secret。

虽然如果我编辑 OAuth2.java 文件并将方法 buildTokenRequestMessage 更改为类似以下的内容,但工作流程可以完美运行

public String buildTokenRequestMessage(String code) throws UnsupportedEncodingException {
    String message = String.format("%s=%s&%s=%s&%s=%s&%s=%s&%s=%s",
            AuthenticationConstants.OAuth2.GRANT_TYPE,
            StringExtensions.URLFormEncode(AuthenticationConstants.OAuth2.AUTHORIZATION_CODE),

            AuthenticationConstants.OAuth2.CODE, StringExtensions.URLFormEncode(code),

            AuthenticationConstants.OAuth2.CLIENT_ID,
            StringExtensions.URLFormEncode(mRequest.getClientId()),

            AuthenticationConstants.OAuth2.REDIRECT_URI,
            StringExtensions.URLFormEncode(mRequest.getRedirectUri())

                  // these are the two lines I've added to make it work
             AuthenticationConstants.OAuth2.CLIENT_SECRET,
            StringExtensions.URLFormEncode("<MY CLIENT SECRET>")

            );
    return message;
}

我做错了吗?如果不是,那么访问客户端密钥的正确方法是什么?

我的实现直接来自演示应用程序,仅更改设置字符串以匹配我的端点。

谢谢

【问题讨论】:

    标签: java android azure oauth-2.0 adal


    【解决方案1】:

    您需要在 Azure AD 门户中将您的应用程序注册为本机应用程序。您不需要本机应用程序的客户端密码。

    【讨论】:

      猜你喜欢
      • 2018-07-15
      • 1970-01-01
      • 1970-01-01
      • 2022-10-20
      • 2018-06-27
      • 2019-07-25
      • 2013-02-21
      • 2010-11-05
      相关资源
      最近更新 更多