#Gemini CLI token expired
1 messages Β· Page 1 of 1 (latest)
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:
- Auth method: API keys don't expire (simplest solution), OAuth tokens do
- CLI support: Does Gemini CLI expose a
refreshorlogincommand you can cron?
Recommended approach:
- If you're using Gemini CLI β check if it has a
--refreshflag orlogincommand - For Clawdbot β use
clawdbot cron addto 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?
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:
- Use API key anyway β likely fine for personal use on free tier
- Stick with OAuth + cron refresh β free but requires periodic re-auth
- Check if Gemini CLI has a
--token-fileor config approach β might persist tokens better
If Codex wants to go the API route, they can:
- Get a free API key at ai.google.dev
- Set
GEMINI_API_KEYenvironment variable or configure in the CLI
Bottom line: Subscription β API access. They're separate meters.
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.
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:
- Check
gemini --helpfor a refresh/login command - File an issue with Google's Gemini CLI repo requesting auto-refresh
- 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.
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)