paascloud/paascloud-master · error · UnapprovedClientAuthenticationException
clientId对应的配置信息不存在:
Error message
clientId对应的配置信息不存在:
What it means
Thrown by PcAuthenticationSuccessHandler.onAuthenticationSuccess when clientDetailsService.loadClientByClientId(clientId) returns null, i.e. no ClientDetails are registered for the clientId decoded from the Authorization header. Message is "clientId对应的配置信息不存在:" concatenated with the offending clientId.
Solutions
- Check the decoded clientId from the Authorization header for typos
- Insert/verify a row in uac_oauth_client_details with the matching client_id
- Confirm the service points at the correct database/environment where the client is registered
- If using in-memory clients, add the clientId to the ClientDetailsService configuration
Example fix
// before
Authorization: Basic d3JvbmdDbGllbnQ6c2VjcmV0 // clientId 'wrongClient' not registered
// after (register then use)
INSERT INTO uac_oauth_client_details(client_id, client_secret, scope, ...) VALUES('paascloud-client', '{cipher}secret', 'all', ...); Defensive patterns
Strategy: validation
Validate before calling
boolean clientRegistered = clientDetailsService.loadClientByClientId(myClientId) != null; // or SELECT COUNT(*) FROM uac_oauth_client_details WHERE client_id = ?
Try / catch
try { return authClient.login(user, pwd); } catch (UnapprovedClientAuthenticationException e) { if (e.getMessage().contains("配置信息不存在")) { /* fix clientId registration */ } throw e; } Prevention
- Keep client registration SQL in migration scripts so every environment has the clients
- Store clientId/clientSecret in per-environment config, never hardcode
- Validate the clientId at application startup with a probe call
- Log the clientId (not the secret) on auth failures for quick diagnosis
When it happens
Trigger: Login request carries an Authorization header with base64 credentials whose clientId part does not exist in the OAuth2 client store (uac_oauth_client_details table / in-memory client config).
Common situations: Typo in clientId; client row deleted or never inserted in the database; client registered in a different environment (dev vs prod DB); in-memory client list changed after a config refactor.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/a233b0c284e58c3d.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/security/PcAuthenticationSuccessHandler.java:68
logger.info("登录成功");
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
if (header == null || !header.startsWith(BEARER_TOKEN_TYPE)) {
throw new UnapprovedClientAuthenticationException("请求头中无client信息");
}
String[] tokens = RequestUtil.extractAndDecodeHeader(header);
assert tokens.length == 2;
String clientId = tokens[0];
String clientSecret = tokens[1];
ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientId);
if (clientDetails == null) {
throw new UnapprovedClientAuthenticationException("clientId对应的配置信息不存在:" + clientId);
} else if (!StringUtils.equals(clientDetails.getClientSecret(), clientSecret)) {
throw new UnapprovedClientAuthenticationException("clientSecret不匹配:" + clientId);
}
TokenRequest tokenRequest = new TokenRequest(MapUtils.EMPTY_MAP, clientId, clientDetails.getScope(), "custom");
OAuth2Request oAuth2Request = tokenRequest.createOAuth2Request(clientDetails);
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(oAuth2Request, authentication);
OAuth2AccessToken token = authorizationServerTokenServices.createAccessToken(oAuth2Authentication);
SecurityUser principal = (SecurityUser) authentication.getPrincipal();
uacUserService.handlerLoginData(token, principal, request);
log.info("用户【 {} 】记录登录日志", principal.getUsername());
response.setContentType("application/json;charset=UTF-8");
response.getWriter().write((objectMapper.writeValueAsString(WrapMapper.ok(token))));View on GitHub (pinned to 781281a950)