Repository: prometheus/prometheus (language: go)

Issue:
Wrong documentation for http_sd_config / authorization / type
### What did you do?

Configured `http_sd_config` with Bearer authorization type. Didn't specify `authorization.type` since docs say it defaults to `Bearer`. The `Authorization` header value is missing the type; it contains only the `authorization.credentials` string.

Manually adding `authorization.type: Bearer` works.

### What did you expect to see?

List of discovered targets.

### What did you see instead? Under which circumstances?

No targets and HTTP 401 in server logs.

### System information

Linux 6.2.0-1010-aws aarch64

### Prometheus version

```text
prometheus, version 2.46.0 (branch: HEAD, revision: cbb69e51423565ec40f46e74f4ff2dbb3b7fb4f0)
  build user:       root@42454fc0f41e
  build date:       20230725-12:37:33
  go version:       go1.20.6
  platform:         linux/arm64
  tags:             netgo,builtinassets,stringlabels
```


### Prometheus configuration file

```yaml
- job_name: gate-icmp
  http_sd_configs:
  - authorization:
      credentials: super_secret_token
    refresh_interval: 3600s
    url: https://some.protected.url.com/prom_sd
```


### Alertmanager version

```text
n/a
```


### Alertmanager configuration file

```yaml
n/a
```


### Logs

```text
prometheus[5970]: ts=2023-08-28T14:31:06.951Z caller=refresh.go:80 level=error component="discovery manager scrape" discovery=http config=gate-icmp msg="Unable to refresh target groups" err="server returned HTTP status 401 Unauthorized"
```



Discussion / hints:
the documentation is correct, it is a bug

Fix patch:
diff --git a/discovery/http/http.go b/discovery/http/http.go
index ec958c6148e..2980d7efdad 100644
--- a/discovery/http/http.go
+++ b/discovery/http/http.go
@@ -99,7 +99,7 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
 	if parsedURL.Host == "" {
 		return fmt.Errorf("host is missing in URL")
 	}
-	return nil
+	return c.HTTPClientConfig.Validate()
 }
 
 const httpSDURLLabel = model.MetaLabelPrefix + "url"


Test patch:
diff --git a/config/config_test.go b/config/config_test.go
index d3288cc90d3..9698bab13c8 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -1857,6 +1857,10 @@ var expectedErrors = []struct {
 		filename: "http_url_no_host.bad.yml",
 		errMsg:   "host is missing in URL",
 	},
+	{
+		filename: "http_token_file.bad.yml",
+		errMsg:   "at most one of bearer_token & bearer_token_file must be configured",
+	},
 	{
 		filename: "http_url_bad_scheme.bad.yml",
 		errMsg:   "URL scheme must be 'http' or 'https'",
diff --git a/config/testdata/http_token_file.bad.yml b/config/testdata/http_token_file.bad.yml
new file mode 100644
index 00000000000..b3d7a35c9ef
--- /dev/null
+++ b/config/testdata/http_token_file.bad.yml
@@ -0,0 +1,6 @@
+scrape_configs:
+  - job_name: foo
+    http_sd_configs:
+      - url: http://foo
+        bearer_token: foo
+        bearer_token_file: foo