【发布时间】:2022-01-18 16:51:49
【问题描述】:
我有以下 KeyCloak 客户端配置,以使用 pkce 身份验证流程:
Realm: REALM
Client ID: pkce-client
Client Protocol: openid-connect
Access Type: public
Standard Flow Enabled: ON
Valid Redirect URIs: http://localhost:4200/
Advanced Settings:
Proof Key for Code Exchange Code Challenge Method: S256
通过 openid_client 使用 iOS 模拟器对 Flutter App 进行身份验证后 https://pub.dev/packages/openid_client 在某些时候我需要退出。
我可以这样做来获取注销 URL:
String localhost = getLocalhost();
var uri = Uri.parse('http://$localhost:8180/auth/realms/REALM');
var clientId = 'pkce-client';
var issuer = await Issuer.discover(uri);
var client = Client(issuer, clientId);
String idT = token.idToken.toCompactSerialization();
Credential credential = client.createCredential(
tokenType: token.tokenType,
refreshToken: token.refreshToken,
idToken: idT,
);
var url;
try {
url = credential.generateLogoutUrl();
} catch (e) {
print("Error during login (refresh) " + e.toString());
}
return url;
但是我如何使用 url 来注销呢?是否可以从 openid_client 完成?
提前致谢
【问题讨论】:
标签: flutter keycloak openid logout