Fix 'Anonymous token is invalid' error with automatic token refresh#30
Open
konard wants to merge 3 commits into
Open
Fix 'Anonymous token is invalid' error with automatic token refresh#30konard wants to merge 3 commits into
konard wants to merge 3 commits into
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: undefined
When VK API returns error 1116 ("Anonymous token is invalid"), the script
now automatically acquires a new access token using the same mechanism
that handles other token-related errors (expired, IP mismatch, missing).
This fix handles the case when VK API treats a user token as anonymous
and rejects it, which can occur when:
- The token format is not recognized properly by VK servers
- There's a mismatch in token validation on VK's side
- The token authentication state has changed
The solution follows the same pattern as PR #31 for handling invalid
access_token errors by detecting the specific error message and
triggering automatic token refresh.
Fixes #16
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Anonymous token is invalid errorThis reverts commit b5386e4.
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.
Summary
This PR fixes issue #16 by adding automatic token refresh when the VK API returns an "Anonymous token is invalid" error (error code 1116).
Problem
The
acceptAllFriendRequestsfunction was failing with the error:{ "error": { "error_code": 1116, "error_msg": "Anonymous token is invalid", "request_params": [ { "key": "method", "value": "execute.acceptAllFriendRequests" } ] } }Root Cause Analysis
After extensive research, I found that:
response_type=token) may sometimes be categorized incorrectly by VK's servers as an "anonymous" tokenexecutemethod with custom stored functions requires proper user authentication tokensSolution
The fix follows the same pattern as PR #31 for handling token errors:
ANONYMOUS_TOKEN_INVALID_ERROR_MESSAGEconstant to detect the specific error messageexecute.shto trigger automatic token refresh when this error occursChanges
execute.shto detect and handle the "Anonymous token is invalid" error messageTest Plan
The fix handles the error gracefully by:
Related Issues
Anonymous token is invaliderror #16User authorization failed: invalid access_token (4).on acceptAllFriendRequests #18 (invalid access_token error)🤖 Generated with Claude Code