为 keyclock authService.performTokenRequest() 函数执行 doInBackground() 时出错
Posted
技术标签:
【中文标题】为 keyclock authService.performTokenRequest() 函数执行 doInBackground() 时出错【英文标题】:An error occurred while executing doInBackground() for keyclock authService.performTokenRequest() function 【发布时间】: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)
【问题讨论】:
【参考方案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
【讨论】:
以上是关于为 keyclock authService.performTokenRequest() 函数执行 doInBackground() 时出错的主要内容,如果未能解决你的问题,请参考以下文章
无法在 Wildfly 中部署 keyclock 快速入门示例战争
Wicket - Keyclock 隐藏 org.keycloak.adapters 调试日志(logback)
使用 Spring Security 5 OAuth2 实现 Keyclock 授权服务器