openclaw - ✅(Solved) Fix [Bug]: Telegram auth routing to OAuth despite API key configuration [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#60920Fetched 2026-04-08 02:45:39
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
1
Participants
Timeline (top)
labeled ×2cross-referenced ×1

I can't get Telegram to use billing API (it's stuck on OAUTH despite all the config changes)

  • openclaw.json configured with mode: "token" (API key)
  • Curl tests with API key work correctly (get billed and shows up in dashboard log)
  • Telegram messages routed through OAuth instead
  • OAuth consumed
  • This prevents API key from being used

Root Cause

I can't get Telegram to use billing API (it's stuck on OAUTH despite all the config changes)

  • openclaw.json configured with mode: "token" (API key)
  • Curl tests with API key work correctly (get billed and shows up in dashboard log)
  • Telegram messages routed through OAuth instead
  • OAuth consumed
  • This prevents API key from being used

Fix Action

Fixed

PR fix notes

PR #60934: fix(auth): respect auth override by filtering profiles (token/oauth) (closes #60930)

Description (problem / solution / changelog)

Summary

  • Problem: Auth profile resolution ignored auth override and selected OAuth profiles even when mode: "token" was configured
  • Why it matters: Telegram and other integrations incorrectly used OAuth, consuming credits instead of billing via API key
  • What changed: Filtered auth profile resolution order to respect auth override (token or oauth) with fallback to original order
  • What did NOT change (scope boundary): No changes to env resolution, custom provider keys, or downstream auth handling

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Auth / tokens

Linked Issue/PR

  • Closes #60920
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: Auth resolution loop iterated over all profiles without considering configured auth override, allowing higher-priority OAuth profiles to be selected
  • Missing detection / guardrail: No filtering or prioritization based on explicit auth mode in config
  • Contributing context (if known): Mixed auth profiles (OAuth + token) combined with default ordering led to unintended selection

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
  • Target test or file: model-auth.ts auth resolution logic
  • Scenario the test should lock in: When auth: "token" is set, only token profiles are selected unless none exist
  • Why this is the smallest reliable guardrail: Directly validates core resolution logic without requiring full integration setup
  • Existing test that already covers this (if any): None
  • If no new test is added, why not: Can be added separately to avoid blocking fix

User-visible / Behavior Changes

  • Auth override (auth: "token" or "oauth") is now strictly respected during profile selection

Diagram (if applicable)

Before:
[request] -> [all profiles considered] -> [OAuth selected] -> [credits used]

After:
[request] -> [filter by auth override] -> [token selected] -> [API key billing]

## Changed files

- `src/agents/model-auth.ts` (modified, +12/-1)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

I can't get Telegram to use billing API (it's stuck on OAUTH despite all the config changes)

  • openclaw.json configured with mode: "token" (API key)
  • Curl tests with API key work correctly (get billed and shows up in dashboard log)
  • Telegram messages routed through OAuth instead
  • OAuth consumed
  • This prevents API key from being used

Steps to reproduce

  1. Configure OpenClaw with API key (set mode: "token" in openclaw.json)
  2. Ensure Anthropic account has both paid credits + API key configured
  3. Send a test message via Telegram to your OpenClaw bot
  4. Check Anthropic dashboard (console.anthropic.com/settings/usage)
    • Message is NOT in usage list
    • Paid credits are consumed instead
  5. For comparison: run curl https://api.anthropic.com/v1/messages -H "x-api-key: YOUR_KEY" ...
    • Curl test DOES appear in usage list
    • Bills to card immediately (bypasses credits)

Expected: Telegram and curl should both use API key Actual: Telegram uses OAuth (consumes credits), curl uses API key (bills to card)

Expected behavior

When OpenClaw is configured with API key (mode: "token"), all message sources (including Telegram) should respect that configuration and use the API key for billing.

Specifically:

  • Telegram messages should bill directly to the card via API key (like curl does)
  • Paid credits should not be consumed
  • API key config should be honored consistently across all interfaces (Telegram, CLI, direct API calls, etc.)

Actual behavior

OAUTH is being used and i'm not being billed

OpenClaw version

2026.04.01

Operating system

macOS

Install method

openclaw update

Model

Anthropic *

Provider / routing chain

Telegram → OpenClaw Gateway → Agent → Anthropic

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

Verify that the openclaw.json configuration is correctly loaded and applied to the Telegram messaging pathway.

Guidance

  • Review the OpenClaw configuration loading process to ensure that the mode: "token" setting is applied to the Telegram integration.
  • Check for any overrides or default settings in the Telegram integration that might be causing it to use OAuth instead of the API key.
  • Compare the configuration and request headers used in the successful curl test to those used in the Telegram messages to identify any differences.
  • Test the Telegram integration with a minimal configuration to isolate if the issue is specific to the current setup.

Example

No specific code example can be provided without more details on the OpenClaw and Telegram integration configurations.

Notes

The issue seems to be related to the configuration or integration of OpenClaw with Telegram, rather than a problem with the API key itself, as evidenced by the successful curl test.

Recommendation

Apply a workaround by re-checking and potentially re-configuring the OpenClaw and Telegram integration settings to ensure consistency with the openclaw.json configuration, as the root cause appears to be related to configuration or integration rather than a version issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When OpenClaw is configured with API key (mode: "token"), all message sources (including Telegram) should respect that configuration and use the API key for billing.

Specifically:

  • Telegram messages should bill directly to the card via API key (like curl does)
  • Paid credits should not be consumed
  • API key config should be honored consistently across all interfaces (Telegram, CLI, direct API calls, etc.)

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING