JanDeDobbeleer/oh-my-posh · error
received empty token
Error message
received empty token
What it means
Ytmda.Authenticate authenticates against the YouTube Music Desktop App Companion API: it requests a code, exchanges it for a token, and stores the token. If requestToken returns no error but the token is an empty string (the server replied 200 with a body whose "token" field is absent/empty), the flow fails with "received empty token" rather than caching a useless empty credential.
Source
Thrown at src/cli/auth/tui/ytmda.go:61
if err != nil {
y.err = err
setState(done)
return
}
y.code = code
setState(token)
y.lastState = token
token, err := y.requestToken(code)
if err != nil {
y.err = err
setState(done)
return
}
if token == "" {
y.err = fmt.Errorf("received empty token")
setState(done)
return
}
cache.Device.Set(auth.YTMDATOKEN, token, cache.INFINITE)
setState(done)
}
func (y *Ytmda) requestCode() (string, error) {
body := fmt.Sprintf(`{"appId": "ohmyposh", "appName": "oh-my-posh", "appVersion": "%s"}`, strings.TrimPrefix(build.Version, "v"))
type codeResponse struct {
Code string `json:"code"`
}
result, err := ytmdaRequest[codeResponse](httplib.MethodPost, codeURL, body, y.env)
View on GitHub (pinned to 0976794618)
Solutions
- Retry authentication and make sure to press Allow in the YTMDA pop-up window before the flow completes
- Verify the YouTube Music Desktop App is up to date so the Companion API returns a proper token payload
- Check Companion API settings in YTMDA (enable companion authorization) and restart the app
- Retry after the API recovers; the error is transient server behavior, not a client bug
Example fix
// before (server returns empty token) err: received empty token // after (user retries with approval) // press Allow in YTMDA, then rerun the authenticate flow
Defensive patterns
Strategy: retry
Type guard
func isEmptyToken(token string) bool { return token == "" } Try / catch
token, err := requestToken(code)
if err != nil {
return err
}
if token == "" {
// wait for the user to press Allow, then retry once
time.Sleep(2 * time.Second)
token, err = requestToken(code)
} Prevention
- Press Allow in the YTMDA pop-up promptly during the exchange
- Keep YouTube Music Desktop App updated so the Companion API returns complete payloads
- Enable companion authorization in YTMDA settings before authenticating
- Treat empty-token responses as 'not yet approved' and retry after a short delay
When it happens
Trigger: POST to /auth/request succeeds at HTTP level and JSON decodes, but the response JSON lacks a non-empty "token" field — e.g. the user has not yet pressed Allow, or the Companion API returns an empty/odd body that still unmarshals cleanly.
Common situations: The YTMDA Companion API is running but the pop-up approval was never confirmed or already expired; an older YTMDA version returns a differently-shaped JSON body; a proxy strips the token field; the request happened before the user clicked Allow.
Related errors
- no elements in the array
- no data found
- Withings API error: <status>
- authentication error: %s - %s
- unable to get data for team %s
AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31).
Data as JSON: /api/errors/b0483518e1c7ed95.
Report an issue: GitHub.