{"record":{"id":"9ef4c897ad181cff","repo":"JanDeDobbeleer/oh-my-posh","slug":"ytmda-token-not-found-please-authenticate-using","errorCode":null,"errorMessage":"YTMDA token not found, please authenticate using `oh-my-posh auth ytmda`","messagePattern":"YTMDA token not found, please authenticate using `oh-my-posh auth ytmda`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/segments/ytm.go","lineNumber":51,"sourceCode":"\n\treturn err == nil\n}\n\ntype ytmdaStatusResponse struct {\n\tVideo struct {\n\t\tAuthor string `json:\"author\"`\n\t\tTitle  string `json:\"title\"`\n\t} `json:\"video\"`\n\tPlayer struct {\n\t\tTrackState int  `json:\"trackState\"`\n\t\tAdPlaying  bool `json:\"adPlaying\"`\n\t} `json:\"player\"`\n}\n\nfunc (y *Ytm) setStatus() error {\n\ttoken, OK := cache.Device.Get[string](auth.YTMDATOKEN)\n\tif !OK || token == \"\" {\n\t\treturn errors.New(\"YTMDA token not found, please authenticate using `oh-my-posh auth ytmda`\")\n\t}\n\n\tstatus, err := y.requestStatus(token)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tswitch status.Player.TrackState {\n\tcase 1, 2: // playing or buffering\n\t\ty.Status = playing\n\t\ty.Icon = y.options.String(PlayingIcon, \"\\uf04b \")\n\tcase -1: // stopped\n\t\ty.Status = stopped\n\t\ty.Icon = y.options.String(StoppedIcon, \"\\uf04d \")\n\tdefault: // paused\n\t\ty.Status = paused\n\t\ty.Icon = y.options.String(PausedIcon, \"\\uf04c \")\n\t}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/ytm.go#L33-L69","documentation":"The ytm segment (YouTube Music Desktop App) requires an auth token cached under the key auth.YTMDATOKEN, obtained via `oh-my-posh auth ytmda`. setStatus throws this error when the cache has no token or the stored string is empty, meaning the user never authenticated or the token was cleared.","triggerScenarios":"Enabled calls setStatus; cache.Device.Get[string](auth.YTMDATOKEN) returns OK=false (key absent) or an empty string. Happens on any machine/profile where `oh-my-posh auth ytmda` was never run or its cache was wiped.","commonSituations":"Fresh install or new machine; cache directory cleaned/deleted; token cleared after YTMDA re-install; running the prompt with the ytm segment enabled in the config but never completing the auth flow.","solutions":["Run `oh-my-posh auth ytmda` to authenticate and store the token","Ensure YTMDA (YouTube Music Desktop App) is installed and its API is enabled","Remove/disable the ytm segment from the prompt config if not using YTMDA","Check that the oh-my-posh device cache persists between sessions (not wiped on reboot)","If auth was run, clear cache and re-authenticate to refresh a stale token"],"exampleFix":"// before: shell config renders ytm segment without token\n{ type = \"ytm\" ... }\n// after: run once first\noh-my-posh auth ytmda","handlingStrategy":"validation","validationCode":"// before enabling the segment, check for the token\nif _, ok := cache.Device.Get[string](auth.YTMDATOKEN); !ok {\n    // prompt the user: oh-my-posh auth ytmda\n}","typeGuard":null,"tryCatchPattern":"token, OK := cache.Device.Get[string](auth.YTMDATOKEN)\nif !OK || token == \"\" {\n    return errTokenMissing // segment hides itself instead of failing the prompt\n}","preventionTips":["Run `oh-my-posh auth ytmda` once per machine after installing YTMDA","Re-authenticate whenever YTMDA is reinstalled","Remove the ytm segment from configs on machines without YTMDA","Avoid wiping the device cache between sessions"],"tags":["auth","token","segment","cache"],"backgroundTag":"missing-auth-token","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}