Install
openclaw skills install qwen-portal-auth-helperAutomate qwen-portal OAuth authentication - solves the interactive TTY problem with tmux, provides monitoring and recovery tools.
openclaw skills install qwen-portal-auth-helperBattle-tested solution for qwen-portal OAuth automation
Solves the "interactive TTY required" problem, prevents cron task failures, and provides full monitoring.
qwen-portal provides free models (2,000 requests/day) but OAuth expires every 1-2 weeks. When it expires:
Qwen OAuth refresh token expired or invalidopenclaw models auth login --provider qwen-portal fails: requires an interactive TTYThis skill provides a complete solution:
# Via ClawHub (recommended)
clawhub install qwen-portal-auth-helper
# Or manually
cd ~/.openclaw/skills/
git clone <repository>
~/.openclaw/skills/qwen-portal-auth-helper/scripts/get-qwen-oauth-link.sh
Outputs:
🔗 OAuth Link: https://chat.qwen.ai/authorize?user_code=M17WU0SC
📱 Device Code: M17WU0SC
~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh
Checks all qwen-portal tasks, reports errors, generates actionable report.
# Add to crontab (runs every Monday at 9 AM)
0 9 * * 1 ~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh
# Traditional way (fails in automation):
openclaw models auth login --provider qwen-portal # ❌ Error: requires interactive TTY
# Our solution:
./scripts/get-qwen-oauth-link.sh # ✅ Works in cron, AI assistants, etc.
How it works: Uses tmux to create virtual terminal, captures output before command hangs.
1. Run: check-qwen-auth.sh
→ Identifies failing tasks, shows error details
2. Run: get-qwen-oauth-link.sh
→ Provides OAuth link and device code
3. User: Click link, authenticate in browser
→ Authorization completes automatically
4. Test: openclaw cron run <task-id>
→ Verifies authentication works
5. Reset: Scripts help reset task state
→ Tasks return to normal operation
Monday 9 AM: check-qwen-auth.sh runs automatically
If issues detected: Email/notification sent
Preventative action: Re-authenticate before expiry
AI assistants can't provide interactive TTY. This skill enables them to:
Ensure scheduled tasks don't fail due to expired OAuth:
Standardized approach for teams:
New OpenClaw users inevitably hit this issue. This skill provides:
# The core technique:
tmux new-session -d -s qwen-oauth "openclaw models auth login --provider qwen-portal"
sleep 5
tmux capture-pane -t qwen-oauth -p | grep -E "(http|https)://"
Key discoveries from real-world testing:
https://chat.qwen.ai/authorize?user_code=XXXXXXX&client=qwen-code◑ Waiting for Qwen OAuth approval...)Even after successful authentication, cron tasks may remain in error state:
// Before fix:
"state": {"lastStatus": "error", "consecutiveErrors": 10}
// After fix (manual reset needed):
"state": {"lastStatus": "pending", "consecutiveErrors": 0}
This skill includes scripts to reset these states automatically.
# Combine with system-maintenance skill
~/.openclaw/skills/system-maintenance/scripts/daily-maintenance.sh
~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh
# Use with agent-team-orchestration
# Assign OAuth recovery as a specialized team task
# Daily quick check (lightweight)
0 9 * * * ~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh --quick
# Weekly comprehensive check
0 9 * * 1 ~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh --full
# Alert on critical issues immediately
*/30 * * * * ~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh --alert-only
The pattern works for other services with similar issues:
# 1. Check what's wrong
./check-qwen-auth.sh
# 2. Get new OAuth link
./get-qwen-oauth-link.sh
# Output: Link and code to give to user
# 3. After user authenticates, verify
openclaw cron run 71628635-03e3-414b-865b-e427af4e804f
openclaw cron runs --id 71628635-03e3-414b-865b-e427af4e804f
# 4. Reset task states if needed
./scripts/reset-task-state.py 71628635-03e3-414b-865b-e427af4e804f
# Add to crontab for Monday morning checks
crontab -l | grep -q "check-qwen-auth" || echo "0 9 * * 1 ~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh >> ~/.openclaw/logs/qwen-check.log" | crontab -
# Review weekly reports
cat /tmp/qwen-auth-report-*.md | less
When user reports news tasks failing:
1. Run check-qwen-auth.sh to confirm qwen-portal issue
2. Run get-qwen-oauth-link.sh to get authentication link
3. Provide link and code to user
4. Guide user through browser authentication
5. Verify fix with test run
6. Reset task states if needed
Solution: Use timeout and active output capture (implemented in scripts)
Solution: Robust regex that handles colored output (included)
Solution: Manual state reset scripts (provided)
Solution: Batch processing in monitoring script
Solution: Weekly monitoring catches it early
This skill was developed from solving actual production issues on 2026-03-09:
.learnings/ systemFound a better way? Have another OAuth provider with similar issues?
examples/ directory for common scenariosdocs/troubleshooting.md for known issues# Install from ClawHub
clawhub install qwen-portal-auth-helper
# Or clone directly
cd ~/.openclaw/skills
git clone https://github.com/your-username/qwen-portal-auth-helper.git
# 1. Test the scripts
cd ~/.openclaw/skills/qwen-portal-auth-helper
./scripts/get-qwen-oauth-link.sh --test-only
./scripts/check-qwen-auth.sh
# 2. Set up monitoring
echo "0 9 * * 1 $(pwd)/scripts/check-qwen-auth.sh" | crontab -
# 3. Document your qwen-portal tasks
# Update examples/your-tasks.md with your task IDs
# Simulate a failure scenario
openclaw cron run <your-qwen-portal-task-id>
# Check monitoring catches it
./scripts/check-qwen-auth.sh
# Practice recovery workflow
./scripts/get-qwen-oauth-link.sh --dry-run
Remember: qwen-portal OAuth expires every 1-2 weeks.
Solution: Weekly monitoring + this skill = no more surprises.
Skill version: 1.0.0 | Based on 2026-03-09 battle-tested experience