Qwen Portal Auth Helper
by @jazzqi
Automate qwen-portal OAuth authentication - solves the interactive TTY problem with tmux, provides monitoring and recovery tools.
clawhub install qwen-portal-auth-helperπ About This Skill
name: qwen-portal-auth-helper description: Automate qwen-portal OAuth authentication - solves the interactive TTY problem with tmux, provides monitoring and recovery tools. metadata: { "openclaw": { "requires": { "bins": ["tmux", "openclaw"] }, "category": "authentication", "tags": ["qwen-portal", "oauth", "automation", "troubleshooting"], "version": "1.0.0", "author": "Bessent (based on 2026-03-09 practical experience)" }, }
Qwen Portal Auth Helper
> Battle-tested solution for qwen-portal OAuth automation > Solves the "interactive TTY required" problem, prevents cron task failures, and provides full monitoring.
π¨ The Problem
qwen-portal provides free models (2,000 requests/day) but OAuth expires every 1-2 weeks. When it expires:
1. Cron tasks fail with: Qwen OAuth refresh token expired or invalid
2. openclaw models auth login --provider qwen-portal fails: requires an interactive TTY
3. Manual intervention required, breaking automation
4. Tasks remain in error state even after authentication fix
π‘ The Solution
This skill provides a complete solution:
π¦ Installation
# Via ClawHub (recommended)
clawhub install qwen-portal-auth-helperOr manually
cd ~/.openclaw/skills/
git clone
π οΈ Quick Start
Get OAuth Link (when authentication expired)
~/.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
Check Authentication Health
~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh
Checks all qwen-portal tasks, reports errors, generates actionable report.Setup Weekly Monitoring
# Add to crontab (runs every Monday at 9 AM)
0 9 * * 1 ~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh
π§ Core Features
1. OAuth Link Automation
# Traditional way (fails in automation):
openclaw models auth login --provider qwen-portal # β Error: requires interactive TTYOur 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.
2. Health Monitoring
3. Recovery Tools
4. Best Practices Documentation
π Complete Workflow
When tasks start failing:
1. Run: check-qwen-auth.sh
β Identifies failing tasks, shows error details2. 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
β Verifies authentication works
5. Reset: Scripts help reset task state
β Tasks return to normal operation
Weekly Maintenance:
Monday 9 AM: check-qwen-auth.sh runs automatically
If issues detected: Email/notification sent
Preventative action: Re-authenticate before expiry
π― Use Cases
1. AI Assistants & Automation
AI assistants can't provide interactive TTY. This skill enables them to:2. Cron Task Reliability
Ensure scheduled tasks don't fail due to expired OAuth:3. Team Collaboration
Standardized approach for teams:4. New User Onboarding
New OpenClaw users inevitably hit this issue. This skill provides:π Technical Details
How OAuth Link Extraction Works
# 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...)Task State Management
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.
π Monitoring & Alerting
What We Monitor
1. Task Status: Error vs OK 2. Consecutive Errors: >3 triggers warning 3. Last Success Time: Tasks not running recently 4. OAuth Expiry Estimate: Based on 1-2 week patternAlert Thresholds
Reports Generated
π Advanced Usage
Integration with Other Skills
# Combine with system-maintenance skill
~/.openclaw/skills/system-maintenance/scripts/daily-maintenance.sh
~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.shUse with agent-team-orchestration
Assign OAuth recovery as a specialized team task
Custom Monitoring Schedule
# Daily quick check (lightweight)
0 9 * * * ~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh --quickWeekly comprehensive check
0 9 * * 1 ~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh --fullAlert on critical issues immediately
*/30 * * * * ~/.openclaw/skills/qwen-portal-auth-helper/scripts/check-qwen-auth.sh --alert-only
Extending for Other OAuth Providers
The pattern works for other services with similar issues: 1. GitHub OAuth 2. Google OAuth 3. Other AI model providers with device-code flowπ Examples
Example 1: Quick Recovery
# 1. Check what's wrong
./check-qwen-auth.sh2. 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-e427af4e804f4. Reset task states if needed
./scripts/reset-task-state.py 71628635-03e3-414b-865b-e427af4e804f
Example 2: Proactive Maintenance
# 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
Example 3: Integration with AI Assistant
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
β οΈ Common Pitfalls & Solutions
Pitfall 1: Command hangs indefinitely
Solution: Use timeout and active output capture (implemented in scripts)Pitfall 2: ANSI escape codes break parsing
Solution: Robust regex that handles colored output (included)Pitfall 3: Task state doesn't reset automatically
Solution: Manual state reset scripts (provided)Pitfall 4: Multiple qwen-portal tasks failing
Solution: Batch processing in monitoring scriptPitfall 5: OAuth expires at inconvenient times
Solution: Weekly monitoring catches it earlyπ Maintenance Schedule
Weekly (Essential)
Monthly (Recommended)
Quarterly (Optional)
π€ Community & Support
Based on Real Experience
This skill was developed from solving actual production issues on 2026-03-09:.learnings/ systemContributing
Found a better way? Have another OAuth provider with similar issues? 1. Fork the repository 2. Add your improvements 3. Submit pull request 4. Help others avoid the same pitfallsGetting Help
examples/ directory for common scenariosdocs/troubleshooting.md for known issuesπ Benefits
For Individual Users
For Teams
For Community
π Getting Started
Installation
# Install from ClawHub
clawhub install qwen-portal-auth-helperOr clone directly
cd ~/.openclaw/skills
git clone https://github.com/your-username/qwen-portal-auth-helper.git
First-Time Setup
# 1. Test the scripts
cd ~/.openclaw/skills/qwen-portal-auth-helper
./scripts/get-qwen-oauth-link.sh --test-only
./scripts/check-qwen-auth.sh2. 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
Verify It Works
# Simulate a failure scenario
openclaw cron run Check monitoring catches it
./scripts/check-qwen-auth.shPractice 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*