Skip to content

Handle invalid OAuth token validation responses#8

Merged
altaywtf merged 1 commit intoputdotio:masterfrom
chillardinho:fix-validate-token-invalid-result
May 8, 2026
Merged

Handle invalid OAuth token validation responses#8
altaywtf merged 1 commit intoputdotio:masterfrom
chillardinho:fix-validate-token-invalid-result

Conversation

@chillardinho
Copy link
Copy Markdown

What

Treat ValidateToken responses with result:false as invalid tokens instead of returning (nil, nil). Also return ErrInvalidToken when the validation response has no user_id.

Why

The Put.io OAuth validation endpoint can return HTTP 200 with a payload like:

{"result":false,"token_id":null,"token_scope":null,"user_id":null}

The current client only decodes user_id, so callers see (nil, nil) and have to guess whether the token is invalid or the response is malformed. Returning a sentinel error gives callers a reliable path for stale/invalid tokens.

Compatibility

The ValidateToken signature is unchanged. Valid responses still return the user ID. Invalid or missing-user responses now return ErrInvalidToken instead of (nil, nil).

Tests

  • go test ./...

@chillardinho chillardinho marked this pull request as ready for review May 7, 2026 12:40
@chillardinho chillardinho force-pushed the fix-validate-token-invalid-result branch from 110fa15 to 70434df Compare May 7, 2026 14:27
@altaywtf altaywtf merged commit aacdbf5 into putdotio:master May 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants