{"record":{"id":"5fefdbddce48f223","repo":"apache/pulsar","slug":"unsupported-authentication-type-type","errorCode":null,"errorMessage":"Unsupported authentication type: ${type}","messagePattern":"Unsupported authentication type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/AuthenticationOAuth2.java","lineNumber":185,"sourceCode":"    }\n\n    @Override\n    public void configure(String encodedAuthParamString) {\n        Map<String, String> params = parseAuthParameters(encodedAuthParamString);\n        String type = params.getOrDefault(CONFIG_PARAM_TYPE, TYPE_CLIENT_CREDENTIALS);\n        if (TYPE_CLIENT_CREDENTIALS.equals(type)) {\n            TokenEndpointAuthMethod authMethod = TokenEndpointAuthMethod.fromValue(\n                    params.getOrDefault(CONFIG_PARAM_TOKEN_ENDPOINT_AUTH_METHOD,\n                            TokenEndpointAuthMethod.CLIENT_SECRET_POST.value()));\n            if (authMethod == TokenEndpointAuthMethod.CLIENT_SECRET_POST) {\n                this.flow = ClientCredentialsFlow.fromParameters(params);\n            } else if (authMethod == TokenEndpointAuthMethod.TLS_CLIENT_AUTH) {\n                this.flow = TlsClientAuthFlow.fromParameters(params);\n            } else {\n                throw new IllegalArgumentException(\"Unsupported auth method: \" + authMethod);\n            }\n        } else {\n            throw new IllegalArgumentException(\"Unsupported authentication type: \" + type);\n        }\n    }\n\n    protected Map<String, String> parseAuthParameters(String encodedAuthParamString) {\n        if (StringUtils.isBlank(encodedAuthParamString)) {\n            throw new IllegalArgumentException(\"No authentication parameters were provided\");\n        }\n        Map<String, String> params;\n        try {\n            params = AuthenticationUtil.configureFromJsonString(encodedAuthParamString);\n        } catch (IOException e) {\n            throw new IllegalArgumentException(\"Malformed authentication parameters\", e);\n        }\n\n        String earlyRefreshPercentStr = params.get(CONFIG_PARAM_EARLY_TOKEN_REFRESH_PERCENT);\n        if (earlyRefreshPercentStr != null) {\n            double percent = parseEarlyRefreshPercent(earlyRefreshPercentStr);\n            this.earlyTokenRefreshPercent = percent;","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/AuthenticationOAuth2.java#L167-L203","documentation":"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>').","triggerScenarios":"Calling configure() with a params JSON whose 'type' key is not 'oauth2' — e.g. 'token', 'basic', or absent.","commonSituations":"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.","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."],"exampleFix":"// before\nauth.configure(\"{\"type\":\"token\",\"token\":\"xyz\"}\"); // throws\n// after\nauth.configure(\"{\"type\":\"oauth2\",\"issuerUrl\":\"https://...\",\"clientId\":\"...\",\"clientSecret\":\"...\"}\");","handlingStrategy":"validation","validationCode":"JSONObject params = new JSONObject(json);\nif (!\"oauth2\".equals(params.optString(\"type\"))) {\n    throw new IllegalStateException(\"AuthenticationOAuth2 requires \\\"type\\\":\\\"oauth2\\\" in auth params\");\n}\nauth.configure(json);","typeGuard":null,"tryCatchPattern":"try {\n    auth.configure(json);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unsupported authentication type\")) {\n        throw new ConfigurationException(\"Auth params must contain \\\"type\\\":\\\"oauth2\\\" for the OAuth2 plugin\", e);\n    }\n    throw e;\n}","preventionTips":["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()."],"tags":["pulsar-client","oauth2","authentication","configuration"],"backgroundTag":"unsupported-auth-type","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}