{"record":{"id":"89ee5e3865d5ed6e","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-simultaneously-use-authorization-basic-89ee5e","errorCode":null,"errorMessage":"cannot simultaneously use `authorization`, `basic_auth, `bearer_token` and `oauth2`","messagePattern":"cannot simultaneously use `authorization`, `basic_auth, `bearer_token` and `oauth2`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/promauth/config.go","lineNumber":735,"sourceCode":"\t}\n\tif opts.BearerTokenFile != \"\" {\n\t\tif actx.getAuthHeader != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot simultaneously use `authorization`, `basic_auth` and `bearer_token_file`\")\n\t\t}\n\t\tif opts.BearerToken != \"\" {\n\t\t\treturn nil, fmt.Errorf(\"both `bearer_token`=%q and `bearer_token_file`=%q are set\", opts.BearerToken, opts.BearerTokenFile)\n\t\t}\n\t\tactx.mustInitFromBearerTokenFile(baseDir, opts.BearerTokenFile)\n\t}\n\tif opts.BearerToken != \"\" {\n\t\tif actx.getAuthHeader != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot simultaneously use `authorization`, `basic_auth` and `bearer_token`\")\n\t\t}\n\t\tactx.mustInitFromBearerToken(opts.BearerToken)\n\t}\n\tif opts.OAuth2 != nil {\n\t\tif actx.getAuthHeader != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot simultaneously use `authorization`, `basic_auth, `bearer_token` and `oauth2`\")\n\t\t}\n\t\tif err := actx.initFromOAuth2Config(baseDir, opts.OAuth2); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot initialize oauth2: %w\", err)\n\t\t}\n\t}\n\tvar tctx tlsContext\n\tif opts.TLSConfig != nil {\n\t\tif err := tctx.initFromTLSConfig(baseDir, opts.TLSConfig); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot initialize tls: %w\", err)\n\t\t}\n\t}\n\theaders, err := parseHeaders(opts.Headers)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot parse headers: %w\", err)\n\t}\n\thd := xxhash.New()\n\tfor _, kv := range headers {\n\t\t_, _ = hd.Write([]byte(kv.key))","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/promauth/config.go#L717-L753","documentation":"Guard in promauth.Config.NewConfig: the oauth2 block is present but getAuthHeader was already set by authorization, basic_auth, or bearer_token, so more than one exclusive auth mechanism is active; the sentinel fires at config-parse time.","triggerScenarios":"Thrown at lib/promauth/config.go:735 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Keep only `oauth2` and delete `authorization`, `basic_auth`, and `bearer_token`/`bearer_token_file` from the scrape config","Or drop `oauth2` and use one of the other auth options exclusively"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}