gpt4 book ai didi

java - ADAL 4 Android 不传递客户端 secret

转载 作者:行者123 更新时间:2023-12-01 12:28:06 25 4
gpt4 key购买 nike

我首先要说的是,我确信这只是我的问题,因为人们可能已经开箱即用,无需编辑 ADAL 4 Android 库而无需编辑源代码。

运行示例程序并使用 token 进行身份验证时,我从 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;
}

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

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

谢谢

最佳答案

您需要在 Azure AD 门户将您的应用程序注册为 native 应用程序。 native 应用程序不需要客户端 key 。

enter image description here

关于java - ADAL 4 Android 不传递客户端 secret ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26178488/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com