apache/pulsar · error · IllegalArgumentException
Unsupported authentication type: ${type}
Error message
Unsupported authentication type: ${type} What it means
AuthenticationOAuth2.configure() first checks that the params 'type' equals 'oauth2'. If the type value is anything else (or missing/blank so it fails the equality check), it throws this IllegalArgumentException ('Unsupported authentication type: <type>').
Source
Thrown at pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/AuthenticationOAuth2.java:185
}
@Override
public void configure(String encodedAuthParamString) {
Map<String, String> params = parseAuthParameters(encodedAuthParamString);
String type = params.getOrDefault(CONFIG_PARAM_TYPE, TYPE_CLIENT_CREDENTIALS);
if (TYPE_CLIENT_CREDENTIALS.equals(type)) {
TokenEndpointAuthMethod authMethod = TokenEndpointAuthMethod.fromValue(
params.getOrDefault(CONFIG_PARAM_TOKEN_ENDPOINT_AUTH_METHOD,
TokenEndpointAuthMethod.CLIENT_SECRET_POST.value()));
if (authMethod == TokenEndpointAuthMethod.CLIENT_SECRET_POST) {
this.flow = ClientCredentialsFlow.fromParameters(params);
} else if (authMethod == TokenEndpointAuthMethod.TLS_CLIENT_AUTH) {
this.flow = TlsClientAuthFlow.fromParameters(params);
} else {
throw new IllegalArgumentException("Unsupported auth method: " + authMethod);
}
} else {
throw new IllegalArgumentException("Unsupported authentication type: " + type);
}
}
protected Map<String, String> parseAuthParameters(String encodedAuthParamString) {
if (StringUtils.isBlank(encodedAuthParamString)) {
throw new IllegalArgumentException("No authentication parameters were provided");
}
Map<String, String> params;
try {
params = AuthenticationUtil.configureFromJsonString(encodedAuthParamString);
} catch (IOException e) {
throw new IllegalArgumentException("Malformed authentication parameters", e);
}
String earlyRefreshPercentStr = params.get(CONFIG_PARAM_EARLY_TOKEN_REFRESH_PERCENT);
if (earlyRefreshPercentStr != null) {
double percent = parseEarlyRefreshPercent(earlyRefreshPercentStr);
this.earlyTokenRefreshPercent = percent;View on GitHub (pinned to 820761864e)
Solutions
- Set "type":"oauth2" in the auth params JSON.
- If the credentials are not OAuth2, use the matching authentication plugin instead of AuthenticationOAuth2.
- Verify the params string actually contains the type key and is valid JSON.
Example fix
// before
auth.configure("{"type":"token","token":"xyz"}"); // throws
// after
auth.configure("{"type":"oauth2","issuerUrl":"https://...","clientId":"...","clientSecret":"..."}"); Defensive patterns
Strategy: validation
Validate before calling
JSONObject params = new JSONObject(json);
if (!"oauth2".equals(params.optString("type"))) {
throw new IllegalStateException("AuthenticationOAuth2 requires \"type\":\"oauth2\" in auth params");
}
auth.configure(json); Try / catch
try {
auth.configure(json);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unsupported authentication type")) {
throw new ConfigurationException("Auth params must contain \"type\":\"oauth2\" for the OAuth2 plugin", e);
}
throw e;
} Prevention
- Always include "type":"oauth2" in the params JSON.
- Use the matching plugin for other auth types instead of forcing them into AuthenticationOAuth2.
- Parse the JSON once yourself to sanity-check required keys before configure().
When it happens
Trigger: Calling configure() with a params JSON whose 'type' key is not 'oauth2' — e.g. 'token', 'basic', or absent.
Common situations: Passing a generic auth params string intended for a different plugin (e.g. ATHENZ/TLS) into the OAuth2 plugin; copying a config sample with a different 'type' value; the type key omitted entirely.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Unsupported auth method: ${authMethod}
- No authentication parameters were provided
- Unsupported token endpoint auth method: ${value}
- certFilePath must not be null
- keyFilePath must not be null
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/5fefdbddce48f223.
Report an issue: GitHub.