Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ADAL 4 Android未传递客户端机密_Java_Android_Azure_Oauth 2.0_Adal - Fatal编程技术网

Java ADAL 4 Android未传递客户端机密

Java ADAL 4 Android未传递客户端机密,java,android,azure,oauth-2.0,adal,Java,Android,Azure,Oauth 2.0,Adal,我首先要说的是,我确信这只是我自己,因为人们可能已经把它开箱即用,而不必编辑adal4android库,也不必编辑源代码 当运行示例程序并使用令牌进行身份验证时,我从AZURE获得一个错误,即它没有在消息体中传递客户机密钥。我可以确认事实上是这样的——它没有传递客户的秘密 虽然如果我编辑OAuth2.java文件并将buildTokenRequestMessage方法更改为如下内容,但工作流工作得非常好 public String buildTokenRequestMessage(String

我首先要说的是,我确信这只是我自己,因为人们可能已经把它开箱即用,而不必编辑adal4android库,也不必编辑源代码

当运行示例程序并使用令牌进行身份验证时,我从AZURE获得一个错误,即它没有在消息体中传递客户机密钥。我可以确认事实上是这样的——它没有传递客户的秘密

虽然如果我编辑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;
}
公共字符串buildTokenRequestMessage(字符串代码)引发不支持的DencodingException{
String message=String.format(“%s=%s&%s=%s&%s=%s&%s=%s&%s=%s”,
AuthenticationConstants.OAuth2.GRANT_类型,
StringExtensions.URLFormEncode(AuthenticationConstants.OAuth2.AUTHORIZATION_代码),
AuthenticationConstants.OAuth2.CODE,StringExtensions.URLFormEncode(代码),
AuthenticationConstants.OAuth2.CLIENT_ID,
StringExtensions.URLFormEncode(mRequest.getClientId()),
AuthenticationConstants.OAuth2.REDIRECT_URI,
StringExtensions.URLFormEncode(mRequest.getRedirectUri())
//这是我为使它工作而添加的两行代码
AuthenticationConstants.OAuth2.CLIENT_SECRET,
StringExtensions.URLFormEncode(“”)
);
返回消息;
}
我做错什么了吗?如果没有,访问客户机机密的正确方法是什么

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


谢谢

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