Fix auth-error classification and update token extraction docs - #13
Open
martparve wants to merge 1 commit into
Open
Fix auth-error classification and update token extraction docs#13martparve wants to merge 1 commit into
martparve wants to merge 1 commit into
Conversation
Plaud rejects a bad/expired/wrong token with HTTP 200 and an in-body status code (-3900 "invalid auth header"). The client mapped that to 'invalid_response' -> "unexpected API response format. Retry...", which is misleading: retrying never helps and the real cause (wrong token) is hidden. Classify these envelopes as 'auth' so users get an actionable "re-save a fresh token" message. Also rewrite the README token section: localStorage "tokenstr" no longer exists, and the frillSsoToken in localStorage is the feedback-widget SSO token, not the API token. Document grabbing the live Bearer access token from the Network tab (or a fetch/XHR console hook) instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two issues, found while setting the plugin up against a live account:
Misleading error on a bad/expired token. Plaud rejects a wrong token with
HTTP 200and an in-body status code, e.g.{"status":-3900,"msg":"invalid auth header"}. The client mapped any non-success in-body status toinvalid_response-> user-facing "unexpected API response format. Retry and inspect logs if it persists." Retrying never helps, and the real cause (wrong/expired token) is hidden. This sent me down a long debugging path before I realized it was just auth.Obsolete token instructions.
localStorage.getItem("tokenstr")no longer exists in the Plaud web app. Worse,localStoragenow contains apld_<id>:frillSsoTokenJWT whose payload is only{email,id,name}-- that's the Frill feedback-widget SSO token, not the API token, and pasting it produces exactly the-3900 "invalid auth header"rejection above. The real credential is theBeareraccess token (client_id:"web"in its payload) sent on every API request.Changes
src/plaud-api.ts: newisAuthFailureEnvelope()-- non-success in-body status that looks auth-related (status:-3900, or a msg matching auth/token/unauthorized/forbidden/login) now throws categoryauthinstead ofinvalid_response.src/main.ts: theauthmessage now tells the user the token is invalid/expired and to extract a fresh one.test/plaud-api-client.test.mjs: regression test asserting theHTTP 200 / status:-3900envelope maps toauth. Full suite passes (56 tests).README.md: replaced the deadtokenstrsteps with the Network-tab method (plus a fetch/XHR console hook), and a warning about thefrillSsoTokentrap. Also notes the access token is short-lived (~24h).Notes
The API client itself (
/file/simple/web,Bearerauth,data_file_listparsing) was already correct against the live API -- no transport changes needed.🤖 Generated with Claude Code