diff --git a/README.md b/README.md index cdacaeb0..eb99c5db 100644 --- a/README.md +++ b/README.md @@ -330,7 +330,7 @@ Please be aware that it's perfectly normal for the authentication server to rece } ``` -This happens because a RTSP client doesn't provide credentials until it is asked to. In order to receive the credentials, the authentication server must reply with status code `401` - the client will then send credentials. +This happens because a RTSP client doesn't provide credentials until it is asked to. In order to receive the credentials, the authentication server must reply with status code `401`, then the client will send credentials. ### Encrypt the configuration diff --git a/internal/core/external_auth.go b/internal/core/external_auth.go index 25e448b6..bd14e628 100644 --- a/internal/core/external_auth.go +++ b/internal/core/external_auth.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "io" "net/http" "github.com/google/uuid" @@ -59,7 +60,11 @@ func externalAuth( defer res.Body.Close() if res.StatusCode < 200 || res.StatusCode > 299 { - return fmt.Errorf("bad status code: %d", res.StatusCode) + if resBody, err := io.ReadAll(res.Body); err == nil { + return fmt.Errorf("external authentication replied with code %d: %s", res.StatusCode, resBody) + } + + return fmt.Errorf("external authentication replied with code %d", res.StatusCode) } return nil