gpt4 book ai didi

android - MSAL Android :Missing required tokens of type: {0} while acquireToken

转载 作者:行者123 更新时间:2023-12-02 05:54:27 24 4
gpt4 key购买 nike

我正在集成 MSAL 2.2.1进入 Android 应用程序。

  1. 我已在 Azure b2c 门户中注册了该应用。
  2. 生成签名并将其添加到 Azure b2c 门户。
  3. 在尝试获取 token 时获得登录页面。
  4. 成功登录后,MSAL 重定向到我们的应用。但不是 onSuccess 而是 onError 并带有以下堆栈跟踪。

onError:缺少类型所需的 token :{0}

2021-10-05 03:16:21.310 9573-9573/com.test.msal W/System.err: com.microsoft.identity.client.exception.MsalClientException: Missing required tokens of type: {0}
2021-10-05 03:16:21.310 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.client.internal.controllers.MsalExceptionAdapter.msalExceptionFromBaseException(MsalExceptionAdapter.java:51)
2021-10-05 03:16:21.310 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.client.PublicClientApplication$18.onError(PublicClientApplication.java:1903)
2021-10-05 03:16:21.310 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.client.PublicClientApplication$18.onError(PublicClientApplication.java:1894)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.controllers.CommandDispatcher.commandCallbackOnError(CommandDispatcher.java:447)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.controllers.CommandDispatcher.access$800(CommandDispatcher.java:82)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.controllers.CommandDispatcher$3.run(CommandDispatcher.java:429)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at android.os.Handler.handleCallback(Handler.java:883)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at android.os.Handler.dispatchMessage(Handler.java:100)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at android.os.Looper.loop(Looper.java:214)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7697)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: Caused by: com.microsoft.identity.common.exception.ClientException: Missing required tokens of type: {0}
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Strategy.validateTokensAreInResponse(MicrosoftStsOAuth2Strategy.java:638)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Strategy.validateTokenResponse(MicrosoftStsOAuth2Strategy.java:577)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Strategy.validateTokenResponse(MicrosoftStsOAuth2Strategy.java:87)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.providers.oauth2.OAuth2Strategy.validateTokenResponse(OAuth2Strategy.java:174)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.providers.oauth2.OAuth2Strategy.requestToken(OAuth2Strategy.java:166)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.controllers.BaseController.performTokenRequest(BaseController.java:294)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.controllers.LocalMSALController.acquireToken(LocalMSALController.java:170)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.commands.InteractiveTokenCommand.execute(InteractiveTokenCommand.java:67)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.commands.InteractiveTokenCommand.execute(InteractiveTokenCommand.java:39)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.controllers.CommandDispatcher.executeCommand(CommandDispatcher.java:381)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.controllers.CommandDispatcher.access$000(CommandDispatcher.java:82)
2021-10-05 03:16:21.311 9573-9573/com.test.msal W/System.err: at com.microsoft.identity.common.internal.controllers.CommandDispatcher$4.run(CommandDispatcher.java:584)

我的请求代码如下所示:

application.acquireToken(requireActivity(),arrayOf("openid", "offline_access"),object : AuthenticationCallback {

我已在 Azure b2c 门户中授予这些权限。

但仍然无法获取 token 。有人可以帮忙解决这个问题吗?提前致谢。

最佳答案

我通过使用我的客户端 ID 作为范围类型解决了这个问题:

public static List<String> getScopes() {
return Arrays.asList(
"your-client-id-here");
}

关于android - MSAL Android :Missing required tokens of type: {0} while acquireToken,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69442788/

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