【问题标题】:An error occurred while executing doInBackground() for keyclock authService.performTokenRequest() function为 keyclock authService.performTokenRequest() 函数执行 doInBackground() 时出错
【发布时间】:2021-04-16 06:13:48
【问题描述】:

在整合 Keyclock SDK 时, 我尝试交换授权码以访问令牌

authService.performTokenRequest(
resp.createTokenExchangeRequest(),
new AuthorizationService.TokenResponseCallback() {
  @Override public void onTokenRequestCompleted(
        TokenResponse resp, AuthorizationException ex) {
      if (resp != null) {
        // exchange succeeded
      } else {
        // authorization failed, check ex for more details
      }
    }
});

我收到以下错误,

  java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:354)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
    at java.util.concurrent.FutureTask.run(FutureTask.java:271)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
 Caused by: java.lang.IllegalArgumentException: only https connections are permitted
    at net.openid.appauth.Preconditions.checkArgument(Preconditions.java:116)
    at net.openid.appauth.connectivity.DefaultConnectionBuilder.openConnection(DefaultConnectionBuilder.java:51)
    at net.openid.appauth.AuthorizationService$TokenRequestTask.doInBackground(AuthorizationService.java:418)
    at net.openid.appauth.AuthorizationService$TokenRequestTask.doInBackground(AuthorizationService.java:395)
    at android.os.AsyncTask$2.call(AsyncTask.java:333)

【问题讨论】:

    标签: android android-asynctask keycloak android-backup-service appauth


    【解决方案1】:

    对于那些正在使用flutter_appauth 插件的人。

    您可以通过将allowInsecureConnections 设置为true 来解决此问题。

    AuthorizationTokenRequest(
            "CLIENT_ID",
            "REDIRECT_URL",
            issuer: 'ISSUER',
            scopes: ['openid', 'profile', 'offline_access','email'],
            allowInsecureConnections:true// <-- add this
    )
    

    【讨论】:

      【解决方案2】:

      日志基本清晰

      only https connections are permitted
      

      我想你的答案就在这里:

      Android 8: Cleartext HTTP traffic not permitted

      更新:

      查看 Github 存储库后,我发现问题中有此错误

      Error: only https connections are permitted

      【讨论】:

        猜你喜欢
        • 2015-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-09
        • 2011-12-05
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多