当我尝试验证令牌时,oauth2-security msf4j 返回空指针异常,但没有提供更多详细信息。在调试时,getValidatedTokenResponse 似乎返回空,因此 NPE 即将到来:我验证了令牌和配置,一切似乎都很好。
private boolean validateToken(String authHeader) throws MSF4JSecurityException {
String accessToken = this.extractAccessToken(authHeader);
String responseStr = this.getValidatedTokenResponse(accessToken);
Map responseData = this.getResponseDataMap(responseStr);
if(!Boolean.parseBoolean((String)responseData.get("active"))) {
throw new MSF4JSecurityException(SecurityErrorCode.AUTHENTICATION_FAILURE, "Invalid Access token.");
} else {
return true;
}
}
当我使用 spring security 来验证令牌时,它工作正常..