glanceapp/glance · error

no token found in challenge page

Error message

no token found in challenge page

What it means

Thrown by fetchRedditLoidCookie (internal/glance/widget-reddit.go:420) when the challenge page did match redditChallengePattern but the second regex, redditTokenPattern, found no token. Both the challenge string and the token must be extracted to build the solution URL (?solution=...&js_challenge=1&token=...); a page that contains the challenge markup but not the token means Reddit altered only the token part of the page (or the match in 120 is a false positive on unrelated HTML).

Source

Thrown at internal/glance/widget-reddit.go:420

	if response.StatusCode != http.StatusOK {
		return "", fmt.Errorf("unexpected status code %d when requesting challenge page", response.StatusCode)
	}

	challengeBody, err := io.ReadAll(response.Body)
	if err != nil {
		return "", err
	}

	challengeMatches := redditChallengePattern.FindSubmatch(challengeBody)
	tokenMatches := redditTokenPattern.FindSubmatch(challengeBody)

	if challengeMatches == nil {
		return "", fmt.Errorf("no JS challenge found")
	}

	if tokenMatches == nil {
		return "", fmt.Errorf("no token found in challenge page")
	}

	challengeStr := string(challengeMatches[1])
	token := string(tokenMatches[1])
	solution := challengeStr + challengeStr // the JS does: e + e

	params := url.Values{
		"solution":     {solution},
		"js_challenge": {"1"},
		"token":        {token},
	}
	request, err = http.NewRequest("GET", "https://www.reddit.com/?"+params.Encode(), nil)
	if err != nil {
		return "", err
	}

	setBrowserUserAgentHeader(request)

View on GitHub (pinned to 91324e8de7)

Solutions

  1. Update Glance to the latest version (token/challenge regexes are updated together when Reddit changes)
  2. Verify with curl -A <browser-UA> https://www.reddit.com/ that the challenge page still contains both the challenge and token fields
  3. Try from a different IP/network to exclude block pages
  4. If a cached loid cookie exists, wait for network conditions to change — Glance reuses the cached value
Defensive patterns

Strategy: retry

Try / catch

if err != nil && strings.Contains(err.Error(), "no token found in challenge page") {
    // same class as 'no JS challenge found': page-shape drift; retry later
}

Prevention

When it happens

Trigger: The 200 response body contains something matching redditChallengePattern but nothing matching redditTokenPattern: partial Reddit page redesign where the token moved, a truncated response body (connection reset mid-read is a different error, but truncated HTML from a proxy is not), or the challenge pattern matching stale/unrelated markup.

Common situations: Reddit A/B-testing a new challenge page variant, old Glance version after a partial Reddit change, proxies or middleboxes stripping script blocks containing the token.

Related errors


AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15). Data as JSON: /api/errors/8ea73d263fa248a8. Report an issue: GitHub.