我首先要说的是,我确定只有我自己,因为人们可能已经开箱即用,无需编辑 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;
}
难道我做错了什么?如果不是,那么访问客户端密码的正确方法是什么?
我的实现直接来自演示应用程序,只有更改设置字符串以匹配我的端点。
谢谢