AlexxIT/go2rtc · error

milesone: authentication failed:

Error message

milesone: authentication failed: 

What it means

GetToken performs a login POST to the Milestone Mobile server; any non-200 status is reported as this error with the HTTP status line. It means the Milestone server rejected the authentication request before a session token could be read.

Solutions

  1. Verify Milestone username/password and that the user has Mobile Server (MIP) access rights
  2. Check the server URL/port points to the Milestone Mobile server, not the management server
  3. Inspect res.Status in the message (e.g. 401 Unauthorized) to narrow the cause
  4. Confirm network path/proxy isn't intercepting the request and returning an error page
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(serverURL)
if err != nil {
	return err
}
if u.Scheme != "https" && u.Scheme != "http" {
	return errors.New("milestone server must be http(s) URL")
}

Try / catch

if err := milestone.GetToken(server, user, pass); err != nil {
	if strings.Contains(err.Error(), "authentication failed: 401") {
		// prompt for new credentials
	}
}

Prevention

When it happens

Trigger: Calling milestoneClient with wrong username/password, a user without Mobile Server access, wrong server address/port, or a gateway returning 401/403/404 instead of the expected OK.

Common situations: Password changed in Milestone Management Client; user account disabled; connecting to the wrong port (not the Mobile Server port); reverse proxy stripping auth or returning HTML error pages.

Understand the failure class

Related errors


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/f4d80e18708f884c. Report an issue: GitHub.

Appendix: source

Thrown at internal/webrtc/milestone.go:54

		"username":   m.query["username"],
		"password":   m.query["password"],
	}

	req, err := http.NewRequest("POST", m.url+"/IDP/connect/token", strings.NewReader(data.Encode()))
	if err != nil {
		return err
	}
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

	// support httpx protocol
	res, err := tcp.Do(req)
	if err != nil {
		return err
	}
	defer res.Body.Close()

	if res.StatusCode != http.StatusOK {
		return errors.New("milesone: authentication failed: " + res.Status)
	}

	var payload map[string]interface{}
	if err = json.NewDecoder(res.Body).Decode(&payload); err != nil {
		return err
	}

	token, ok := payload["access_token"].(string)
	if !ok {
		return errors.New("milesone: token not found in the response")
	}

	m.token = token

	return nil
}

func parseFloat(s string) float64 {

View on GitHub (pinned to c245815e75)