tonhowtf/omniget · error · Error

Spotify SDK device not ready

Error message

Spotify SDK device not ready

What it means

Raised by fetch_access_token when the playbackAccessToken object lacks a string 'value' field. The value is the opaque token payload embedded in authenticated clip URLs; without it the library cannot construct the download URL, so it returns an error after having already extracted the signature.

Solutions

  1. Log token_obj and verify the GQL query requests the value field inside playbackAccessToken.
  2. Update field names/pointers if Twitch renamed the field.
  3. Check the clip's accessibility (geo/auth restrictions can yield empty token payloads).
  4. Retry once — transient partial tokens do occur — then fail with the payload logged.

Example fix

// before
let value = token_obj
    .get("value")
    .and_then(|v| v.as_str())
    .ok_or_else(|| anyhow!("Token sem value"))?
    .to_string();
// after
let value = token_obj.get("value")
    .and_then(|v| v.as_str())
    .ok_or_else(|| anyhow!("Token sem value: {}", token_obj))? // log payload
    .to_string();
Defensive patterns

Strategy: type-guard

Type guard

fn value_of(token_obj: &serde_json::Value) -> Option<&str> {
    token_obj.get("value").and_then(|v| v.as_str()).filter(|v| !v.is_empty())
}

Try / catch

// Require both parts of the token before building URLs
let (Some(sig), Some(val)) = (signature_of(&t), value_of(&t)) else {
    anyhow::bail!("incomplete playback token: {}", t);
};

Prevention

When it happens

Trigger: token_obj.get("value").and_then(|v| v.as_str()) returns None — 'value' missing, null, or not a string inside the playbackAccessToken object.

Common situations: GQL schema change to the playbackAccessToken contract; partial/degraded token responses from Twitch for restricted clips; proxy or middleware stripping fields; incorrect manual GQL query omitting the value selector.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/0ba4f008bf7d608e. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/study-music/spotify-sdk.svelte.ts:238

          };
          document.head.appendChild(script);
        }
      })();
    }).catch((e) => {
      this.loadingPromise = null;
      throw e;
    });

    return this.loadingPromise;
  }

  async play(opts: {
    uris?: string[];
    contextUri?: string;
    positionMs?: number;
  }): Promise<void> {
    await this.ensureLoaded();
    if (!this.deviceId) throw new Error("Spotify SDK device not ready");
    await pluginInvoke("study", "study:spotify:playback:play", {
      deviceId: this.deviceId,
      uris: opts.uris ?? [],
      contextUri: opts.contextUri,
      positionMs: opts.positionMs,
    });
  }

  async pause(): Promise<void> {
    if (this.player) await this.player.pause();
  }

  async resume(): Promise<void> {
    if (this.player) await this.player.resume();
  }

  async togglePlay(): Promise<void> {
    if (this.player) await this.player.togglePlay();

View on GitHub (pinned to 8600b91f42)