{"record":{"id":"f1f3df8a77ad6166","repo":"apache/pulsar","slug":"unsupported-auth-method-authmethod","errorCode":null,"errorMessage":"Unsupported auth method: ${authMethod}","messagePattern":"Unsupported auth method: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/AuthenticationOAuth2.java","lineNumber":182,"sourceCode":"    @Override\n    public String getAuthMethodName() {\n        return AUTH_METHOD_NAME;\n    }\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);","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/AuthenticationOAuth2.java#L164-L200","documentation":"AuthenticationOAuth2.configure(encodedAuthParamString) parses the params, reads the 'type' key, and dispatches on the 'authMethod' / 'tokenEndpointAuthMethod' parameter. Only client_secret_post and tls_client_auth are handled; any other authMethod value throws this IllegalArgumentException ('Unsupported auth method: <value>').","triggerScenarios":"Calling configure() with a params JSON whose authMethod/tokenEndpointAuthMethod is 'client_secret_basic', 'private_key_jwt', or any value other than client_secret_post/tls_client_auth.","commonSituations":"Reusing an OAuth2 config written for a different library that uses different auth-method names; expecting client_secret_basic to be supported via configure() when it is only available via the factory builder flow; typos like 'client_secret_Post'.","solutions":["Change the authMethod parameter to 'client_secret_post' or 'tls_client_auth'.","If you need client_secret_basic, build via AuthenticationFactoryOAuth2 (which supports it as a flow) instead of configure().","Check exact spelling and value of the authMethod key in the JSON params."],"exampleFix":"// before\n{\"type\":\"oauth2\",\"authMethod\":\"private_key_jwt\", ...} // throws\n// after\n{\"type\":\"oauth2\",\"authMethod\":\"client_secret_post\",\"issuerUrl\":\"...\",\"clientId\":\"...\",\"clientSecret\":\"...\"}","handlingStrategy":"validation","validationCode":"String authMethod = params.optString(\"authMethod\");\nif (!\"client_secret_post\".equals(authMethod) && !\"tls_client_auth\".equals(authMethod)) {\n    throw new IllegalStateException(\"AuthenticationOAuth2.configure supports only client_secret_post/tls_client_auth, got: \" + authMethod);\n}\nauth.configure(paramsJson);","typeGuard":null,"tryCatchPattern":"try {\n    auth.configure(json);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unsupported auth method\")) {\n        throw new ConfigurationException(\"Use client_secret_post or tls_client_auth in params, or build via AuthenticationFactoryOAuth2 for other methods\", e);\n    }\n    throw e;\n}","preventionTips":["Use only client_secret_post or tls_client_auth in the params string.","For client_secret_basic, use AuthenticationFactoryOAuth2 instead of configure().","Validate the authMethod value before calling configure()."],"tags":["pulsar-client","oauth2","authentication","configuration"],"backgroundTag":"unsupported-auth-method","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}