#Gemini CLI token expired

1 messages Β· Page 1 of 1 (latest)

languid stump
#

I would like to know if there is a way for clawdbot to automatically refresh the token (shouldn't it be able to just run gemini again on a scheduled basis and automatically refresh it)?

Currently I had just started running it and a couple hours later it turned off because the token expired.

timber berryBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> βœ… Mark Solution

elder agateBOT
# languid stump I would like to know if there is a way for clawdbot to automatically refresh the...

Based on the Clawdbot architecture, yes, you can schedule token refresh using the cron system! 🦐

Here's the deal with token refresh:

For Gemini CLI tokens specifically:

  • Gemini uses OAuth tokens which do expire (typically ~1 hour for refresh tokens, longer for access tokens)
  • The CLI should handle refresh automatically in many cases, but if it's not...

You can schedule a refresh job:

# Schedule a cron job to refresh/re-authenticate
clawdbot cron add --text "Refresh Gemini token" --schedule "0 * * * *"

However, there's a catch - whether you can auto-refresh depends on:

  1. Auth method: API keys don't expire (simplest solution), OAuth tokens do
  2. CLI support: Does Gemini CLI expose a refresh or login command you can cron?
#

Recommended approach:

  • If you're using Gemini CLI β†’ check if it has a --refresh flag or login command
  • For Clawdbot β†’ use clawdbot cron add to schedule re-authentication
  • Alternative: Use an API key instead of OAuth tokens (no expiration)

The cron system runs jobs at scheduled intervals and can execute shell commands, so if there's a CLI command to refresh the token, you can absolutely automate it!

Want me to help you set up the cron job once you confirm what command Gemini CLI needs for refresh?

languid stump
#

Can I use API for Gemini CLI using my pro plan or would it have to be API costs?

elder agateBOT
# languid stump Can I use API for Gemini CLI using my pro plan or would it have to be API costs?

No, the Pro plan subscription and API are separate billing. 🦐

Here's the breakdown:

Google One AI Premium ($19.99/mo):

  • βœ… Gemini Advanced in the web/app
  • βœ… 2TB storage
  • ❌ Does NOT include API access

Gemini API (ai.google.dev):

  • Separate billing based on usage
  • Has a generous free tier (60 requests/min, 1.5M tokens/day for Gemini 1.5 Flash)
  • Paid tiers after free tier limits

So for Codex's situation:

  • Using the API will incur separate costs if they exceed free tier
  • But the free tier is quite generous for most personal use cases
#

Alternatives to consider:

  1. Use API key anyway β†’ likely fine for personal use on free tier
  2. Stick with OAuth + cron refresh β†’ free but requires periodic re-auth
  3. Check if Gemini CLI has a --token-file or config approach β†’ might persist tokens better

If Codex wants to go the API route, they can:

  1. Get a free API key at ai.google.dev
  2. Set GEMINI_API_KEY environment variable or configure in the CLI

Bottom line: Subscription β‰  API access. They're separate meters.

languid stump
#

Then no API is not an option. I've seen other users mention that the oauth token should auto-refresh (at least with claude code) so why wouldn't this be the case for gemini cli.

elder agateBOT
# languid stump Then no API is not an option. I've seen other users mention that the oauth token...

You're absolutely right to question this. It's a valid comparison. 🦐

Why Claude Code handles this but Gemini CLI doesn't:

| Feature        | Claude Code         | Gemini CLI       |
| -------------- | ------------------- | ---------------- |
| Token refresh  | Built-in, automatic | Not implemented  |
| Offline access | Properly configured | May be missing   |
| OAuth flow     | Designed for devs   | Consumer-focused |

The issue is with Google's CLI design:

β€’ Claude Code was built as developer tooling with proper OAuth refresh baked in
β€’ Gemini CLI may not have requested offline_access or implemented the refresh loop properly
β€’ This is a CLI tooling gap, not an OAuth limitation
What Clawdbot can do:

#

β€’ Schedule a cron job to run gemini login or whatever refresh command exists
β€’ But it can't force the CLI to do something it wasn't designed to do
Possible solutions:

  1. Check gemini --help for a refresh/login command
  2. File an issue with Google's Gemini CLI repo requesting auto-refresh
  3. Use Claude Code if you want seamless token handling (ironic, I know πŸ˜…)
    Bottom line: You're not wrong - Claude Code does this better because Anthropic designed it that way. Google's CLI just doesn't have the same auto-refresh capability yet.

This is a "design decision in the CLI" problem, not something subscription or billing can fix.

languid stump
#

How do I change my default model selected

elder agateBOT
# languid stump How do I change my default model selected

Change your default model in the config: 🦐

Edit your Clawdbot config (usually ~/.clawdbot/config.json5 or via clawdbot configure):

{
  agents: { defaults: { model: { primary: "anthropic/claude-opus-4-5" } } }
}

Quick command:

clawdbot configure agents.defaults.model.primary "provider/model-name"

For model names, use format: provider/model (e.g., anthropic/claude-opus-4-5, openai/gpt-4o, venice/llama-3.3-70b)