1

While integrating Keyclock SDK , I try to exchange authorization code to access token

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
      }
    }
});

I got the following error,

  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)
Subin Babu
  • 1,515
  • 2
  • 24
  • 50

2 Answers2

7

For those who are using the flutter_appauth plugin.

You can solve this problem by setting allowInsecureConnections to true.

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

The log is almost clear

only https connections are permitted

I think your answer is here:

Android 8: Cleartext HTTP traffic not permitted

update:

after I look at the Github repository I find this error in issues

Error: only https connections are permitted

saeedata
  • 901
  • 6
  • 14