{"record":{"id":"fb8aa446e3aa3724","repo":"wtfutil/wtf","slug":"extracting-player-state-failed-please-refresh-or","errorCode":null,"errorMessage":"extracting player state failed! Please refresh or restart WTF","messagePattern":"extracting player state failed! Please refresh or restart WTF","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/spotifyweb/widget.go","lineNumber":140,"sourceCode":"\n\twidget.settings.RefreshInterval = 5 * time.Second\n\n\twidget.initializeKeyboardControls()\n\n\twidget.View.SetWrap(true)\n\twidget.View.SetWordWrap(true)\n\n\treturn &widget\n}\n\nfunc (w *Widget) refreshSpotifyInfos() error {\n\tif w.client == nil || w.playerState == nil {\n\t\treturn errors.New(\"authentication failed! Please log in to Spotify by visiting the following page in your browser: \" + authURL)\n\t}\n\tvar err error\n\tw.playerState, err = w.client.PlayerState()\n\tif err != nil {\n\t\treturn errors.New(\"extracting player state failed! Please refresh or restart WTF\")\n\t}\n\tw.Album = fmt.Sprint(w.playerState.Item.Album.Name)\n\tartists := \"\"\n\tfor _, artist := range w.playerState.Item.Artists {\n\t\tartists += artist.Name + \", \"\n\t}\n\tartists = artists[:len(artists)-2]\n\tw.Artists = artists\n\tw.Title = fmt.Sprint(w.playerState.Item.Name)\n\tw.TrackNumber = w.playerState.Item.TrackNumber\n\tif w.playerState.Playing {\n\t\tw.Status = \"Playing\"\n\t} else {\n\t\tw.Status = \"Paused\"\n\t}\n\treturn nil\n}\n","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/spotifyweb/widget.go#L122-L158","documentation":"After authentication succeeds, refreshSpotifyInfos calls w.client.PlayerState() to fetch current playback. If that API call fails (network problem, expired/revoked token, Spotify outage), the widget wraps the failure in this error and advises refreshing or restarting WTF, since the underlying client state may be stale.","triggerScenarios":"w.client.PlayerState() returns a non-nil err during refresh — e.g. the access token expired and refresh failed, the network dropped mid-poll, or Spotify's API returned an error.","commonSituations":"Long-running WTFUtil session where the Spotify refresh token expired or was revoked (user changed password / logged out all devices); laptop waking from sleep with a dead connection; Spotify API outage or rate limiting.","solutions":["Restart WTFUtil so the spotifyweb client re-authenticates and gets a fresh token.","If it persists, redo the browser OAuth login to obtain a new refresh token.","Check network connectivity to api.spotify.com and any proxy/firewall interference.","Verify system clock is correct — significant skew breaks OAuth token validation."],"exampleFix":"// before: stale token causes PlayerState() to fail every refresh\n// after: force a clean re-auth\n$ rm -f ~/.config/wtf/spotifyweb_token.json  # module token cache\n$ wtfutil  # complete the OAuth login again when prompted","handlingStrategy":"retry","validationCode":"if widget.client == nil {\n    return // re-authenticate first; PlayerState will fail anyway\n}","typeGuard":null,"tryCatchPattern":"if err := widget.refreshSpotifyInfos(); err != nil {\n    if strings.Contains(err.Error(), \"extracting player state failed\") {\n        // back off, then restart the client or full app to re-auth\n        time.Sleep(30 * time.Second)\n    }\n}","preventionTips":["Restart WTFUtil periodically for long-lived sessions with Spotify modules.","Keep the system clock synchronized (OAuth tolerates little skew).","Re-login when you change your Spotify password (revokes tokens)."],"tags":["spotify","api","token-expired","network"],"backgroundTag":"token-refresh-failed","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}