AlexxIT/go2rtc · error

milesone: token not found in the response

Error message

milesone: token not found in the response

What it means

Milestone GetToken's response-shape guard: the token endpoint returned HTTP 200 and the body decoded as JSON, but the 'access_token' field is absent or not a string. The server did not deliver a usable bearer token, so authentication cannot proceed.

Solutions

  1. Log the raw payload to see what the server actually returned (often an HTML error page with 200)
  2. Verify Milestone credentials and that the user has WebRTC permissions
  3. Check for API version mismatches on the Milestone XProtect deployment
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/webrtc/milestone.go:64 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at internal/webrtc/milestone.go:64

	// 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 {
	if s == "" {
		return 0
	}
	f, _ := strconv.ParseFloat(s, 64)
	return f
}

func (m *milestoneAPI) GetOffer() (string, error) {
	request := struct {
		CameraId         string `json:"cameraId"`

View on GitHub (pinned to c245815e75)