Skip to content

Fix invalid access_token (4) error on acceptAllFriendRequests#31

Open
konard wants to merge 3 commits intomainfrom
issue-18-b63dd8f9
Open

Fix invalid access_token (4) error on acceptAllFriendRequests#31
konard wants to merge 3 commits intomainfrom
issue-18-b63dd8f9

Conversation

@konard
Copy link
Copy Markdown
Owner

@konard konard commented Oct 17, 2025

Summary

This PR fixes issue #18 by adding automatic token refresh when the VK API returns an "invalid access_token (4)" error.

Changes

  • Updated execute.sh to detect and handle the "invalid access_token (4)" error message
  • When this error occurs, the script now automatically acquires a new access token using the same mechanism that handles expired tokens and IP address changes

Problem

The acceptAllFriendRequests function was failing with the error:

User authorization failed: invalid access_token (4).

The execute.sh script already handled several token-related errors (expired tokens, IP address changes, and missing tokens), but did not handle the specific "invalid access_token (4)" error.

Solution

Added the invalid access_token error to the list of errors that trigger automatic token refresh. This allows the script to recover gracefully when encountering this error, maintaining the same behavior as other token-related issues.

Fixes #18

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: undefined
@konard konard self-assigned this Oct 17, 2025
This commit fixes issue #18 by adding support for the "invalid access_token (4)" error that occurs when calling acceptAllFriendRequests. The execute.sh script now detects this error and automatically refreshes the access token using the same mechanism used for expired tokens and IP address changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] User authorization failed: invalid access_token (4). on acceptAllFriendRequests Fix invalid access_token (4) error on acceptAllFriendRequests Oct 17, 2025
@konard konard marked this pull request as ready for review October 17, 2025 16:22
konard added a commit that referenced this pull request Oct 17, 2025
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>
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.

User authorization failed: invalid access_token (4). on acceptAllFriendRequests

1 participant