Skip to content

fix: invalidate provider state when OAuth tokens are refreshed#172

Closed
monotykamary wants to merge 1 commit into
anomalyco:devfrom
monotykamary:fix/oauth-token-refresh-sync
Closed

fix: invalidate provider state when OAuth tokens are refreshed#172
monotykamary wants to merge 1 commit into
anomalyco:devfrom
monotykamary:fix/oauth-token-refresh-sync

Conversation

@monotykamary

Copy link
Copy Markdown
Contributor

Summary

  • Fixes "OAuth token has been revoked" errors when multiple opencode instances are running
  • Invalidates cached provider state when OAuth tokens are refreshed to ensure all instances use fresh tokens

Test plan

  • Test with multiple opencode instances running simultaneously
  • Verify OAuth token refresh works without requiring re-authentication
  • Confirm no regression in single-instance usage

🤖 Generated with opencode

Resolves issue where concurrent opencode instances cause "OAuth token has been revoked" errors. When one instance refreshes tokens, other running instances continue using stale cached access tokens, leading to authentication failures.

- Add Provider.invalidateState() to clear cached provider state
- Call invalidateState() in AuthAnthropic.access() after token refresh
- Forces re-initialization with fresh tokens on next API call

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>
@monotykamary
monotykamary marked this pull request as draft June 17, 2025 15:33
@monotykamary

monotykamary commented Jun 17, 2025

Copy link
Copy Markdown
Contributor Author

Actually needs a triple check at some point, not sure if this is the best way.

@thdxr

thdxr commented Jun 17, 2025

Copy link
Copy Markdown
Member

hey appreciate you looking into this but we fixed it a different way - managed to basically add a middleware to the SDK to reuse saved tokens

i didn't put it together multiple instances of opencode was making the issue worse - ty for figure that out helped me track down a fix

@thdxr thdxr closed this Jun 17, 2025
andreipromarketing-dev pushed a commit to andreipromarketing-dev/opencode that referenced this pull request Apr 7, 2026
…nomalyco#188, anomalyco#172, anomalyco#173) (anomalyco#207)

* fix: resolve multiple reported issues (anomalyco#205, anomalyco#182, anomalyco#188, anomalyco#172, anomalyco#173)

- fix(observe.sh): replace triple-quote JSON parsing with stdin pipe to
  prevent ~49% parse failures on payloads with quotes/backslashes/unicode
- fix(hooks.json): correct matcher syntax to use simple tool name regexes
  instead of unsupported logical expressions; move command/path filtering
  into hook scripts; use exit code 2 for blocking hooks
- fix(skills): quote YAML descriptions containing colons in 3 skill files
  and add missing frontmatter to 2 skill files for Codex CLI compatibility
- feat(rules): add paths: filters to all 15 language-specific rule files
  so they only load when working on matching file types
- fix(agents): align model fields with CONTRIBUTING.md recommendations
  (opus for planner/architect, sonnet for reviewers/workers, haiku for
  doc-updater)

* ci: use AgentShield GitHub Action instead of npx

Switch from npx ecc-agentshield to uses: affaan-m/agentshield@v1
for proper GitHub Action demo and marketplace visibility.
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