glanceapp/glance · error
fetching new app access token: %v
Error message
fetching new app access token: %v
What it means
The Reddit widget uses app-only OAuth (client credentials) against oauth.reddit.com, and refreshing the access token failed. The error wraps the result of fetchNewAppAccessToken, which covers request creation, the token POST, non-200 responses, and response decoding — inspect the wrapped message for the specific stage.
Source
Thrown at internal/glance/widget-reddit.go:185
func (widget *redditWidget) fetchSubredditPosts() (forumPostList, error) {
var client requestDoer = redditHTTPClient
var baseURL string
var requestURL string
var headers http.Header
query := url.Values{}
app := &widget.AppAuth
if !app.enabled {
baseURL = "https://www.reddit.com"
headers = http.Header{
"User-Agent": []string{getBrowserUserAgentHeader()},
}
} else {
baseURL = "https://oauth.reddit.com"
if app.accessToken == "" || time.Now().Add(time.Minute).After(app.tokenExpiresAt) {
if err := widget.fetchNewAppAccessToken(); err != nil {
return nil, fmt.Errorf("fetching new app access token: %v", err)
}
}
headers = http.Header{
"Authorization": []string{"Bearer " + app.accessToken},
"User-Agent": []string{app.Name + "/1.0"},
}
}
if widget.Limit > 25 {
query.Set("limit", strconv.Itoa(widget.Limit))
}
if widget.Search != "" {
query.Set("q", widget.Search+" subreddit:"+widget.Subreddit)
query.Set("sort", widget.SortBy)
requestURL = fmt.Sprintf("%s/search.json?%s", baseURL, query.Encode())
} else {View on GitHub (pinned to 91324e8de7)
Solutions
- Read the wrapped error after 'fetching new app access token:' to identify the stage
- Verify the app-auth client-id and client-secret match a Reddit 'installed app'/'script' app
- Test the credential directly: curl -u <id>:<secret> -d 'grant_type=client_credentials' https://www.reddit.com/api/v1/access_token
- Confirm egress/DNS to reddit.com from the glance host
Example fix
# before
subreddit: programming
app-access-token:
client-id: wrong
client-secret: wrong
# after
subreddit: programming
app-access-token:
client-id: <your-app-id>
client-secret: <your-app-secret> Defensive patterns
Strategy: try-catch
Validate before calling
if app.ID == "" || app.Secret == "" {
return errors.New("app-access-token requires client-id and client-secret")
} Try / catch
if err := widget.fetchNewAppAccessToken(); err != nil {
// fall back to unauthenticated www.reddit.com for this cycle
slog.Warn("reddit app auth failed, falling back to public API", "error", err)
widget.AppAuth.enabled = false // for this fetch
} Prevention
- Validate client-id/client-secret are non-empty at config load
- Smoke-test credentials with a curl token request during deployment
- Rotate Reddit secrets with a single glance restart to avoid stale tokens
When it happens
Trigger: Invalid app client ID/secret (Reddit returns 401), missing or default app-auth config, network failure reaching www.reddit.com/api/v1/access_token, or a non-JSON/failed decode of the token response.
Common situations: Wrong client-id/client-secret in the widget config; Reddit app credentials rotated or revoked; egress to reddit.com blocked; system clock skew; token refresh racing on many widgets at once.
Related errors
- application name, client ID and client secret are required
- subreddit is required
- no `{REQUEST-URL}` placeholder specified
- could not solve reddit challenge
- no posts found
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/de8ffbe480d1744d.
Report an issue: GitHub.