sample keycloak integration
kstan79 opened this issue · 9 comments
kstan79 commented
i think the provided example very bad for keycloak user, so I contribute some example of setting for others people to refer, I hope you guys can prepare better sample for community.
final String _clientId = 'keycloak-client-id';
final String _redirectUrl = 'com.domain.appname:/oauthredirect';
final String _issuer = 'https://login.your.url/realms/yourrealm'; // you may put `auth` behind hostname if your keycloak very old
final String _discoveryUrl =
'https://login.your.url/realms/yourrelam/.well-known/openid-configuration';
final String _postLogoutRedirectUrl = 'com.domain.yourapp:/';
...
authorizationEndpoint:
'https://login.your.url/realms/yourrealm/protocol/openid-connect/auth',
tokenEndpoint:
'https://login.your.url/realms/yourrealm/protocol/openid-connect/token',
endSessionEndpoint:
'https://login.your.url/realms/yourrealm/protocol/openid-connect/logout',
.....
final AuthorizationTokenResponse? result =
await _appAuth.authorizeAndExchangeCode(
AuthorizationTokenRequest(
_clientId, _redirectUrl,
serviceConfiguration: _serviceConfiguration,
scopes: _scopes,
preferEphemeralSession: preferEphemeralSession,
clientSecret: '_your_client_secret_obtain_from_somewhere' //original example not include this properties cause authorization never success
),
);