About chanjing-auth
chanjing-auth is a skill for managing Chanjing OAuth authentication across platform features. It guides interactive and headless login, checks status, and helps troubleshoot credentials; it does not make feature API calls.
Key features
- 01Check authentication status
- 02Guide OAuth browser login
- 03Support CI/CD refresh-token authentication
- 04Troubleshoot credential and token issues
- 05Protect tokens with shared credential storage
Use cases
- 01Check whether Chanjing login is active
- 02Guide an agent-assisted Studio login
- 03Configure authentication for CI/CD
- 04Resolve expired or invalid tokens
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ chanjing-ai/ framevideo --skill chanjing-authAfter installing, type/chanjing-authin Claude Code to confirm it loaded.
Details
From the project READMEChanjing OAuth Authentication
Centralized authentication management for all Chanjing platform features (digital humans, TTS, background music, sound effects).
When To Use
- Check if user is authenticated with Chanjing platform
- Guide user through OAuth login flow
- Troubleshoot credential or token issues
- Set up authentication for CI/CD or headless environments
Do NOT use for: Actual API calls to Chanjing services → delegate to feature-specific skills (chanjing-digital-human, etc.)
Quick Start
# Check current auth status
npx framevideo auth status
# Check if authenticated (exit code)
npx framevideo auth status --check
# Get status as JSON
npx framevideo auth status --json
If not authenticated, use one of the authentication methods below.
Core Concepts
OAuth CLI Web Login
The standard authentication flow:
- User runs
framevideo auth loginor clicks login in Studio - CLI opens browser to Chanjing authorization page
- User approves in browser
- Browser redirects to local callback server
- CLI receives token and saves to credential store
- All Chanjing features can now access the platform
Credential Storage
Tokens are stored in ~/.chanjing/credentials (respects CHANJING_CONFIG_DIR env var) in an oauth block:
{
"oauth": {
"access_token": "...",
"refresh_token": "...",
"expires_at": 1234567890
}
}
Never read, print, log, or commit these tokens. Use the shared auth store APIs in packages/cli/src/auth/store.ts.
Plugin API Client
All Chanjing API requests use Authorization: Bearer <access_token> header. The client handles:
- Token refresh when expired
- Automatic retry on 401
- Error reporting
Located at: packages/cli/src/tts/chanjingOpenapi.ts
Authentication Methods
Method 1: Interactive Login (Recommended)
For development and local use:
npx framevideo auth login
Opens browser for OAuth flow. Requires user interaction.
Method 2: Studio Login (Agent-Friendly)
When working with an agent and OAuth is missing:
- Start or reuse preview server:
npx framevideo preview - Open Studio project URL in browser
- Navigate to Digital Human, Voice, or account panel
- Click login button to start OAuth flow
- Complete browser authorization
- Verify with
npx framevideo auth status
Why this is better than CLI-only guidance:
- Visual feedback for user
- Integrated into natural workflow
- Agent can poll status endpoint
Method 3: CI/CD or Headless
For automated environments without browser:
- Obtain refresh token from an interactive login session
- Set
CHANJING_REFRESH_TOKENenvironment variable - CLI will use refresh token to obtain access tokens
Security note: Treat refresh tokens as secrets. Use secure secret management (GitHub Secrets, CI vault, etc.)
Missing Credentials UX
When an agent-authored workflow needs Chanjing features but auth is missing:
If preview is available (preferred):
- Start or reuse
npx framevideo preview - Open Studio project URL in in-app browser
- Navigate to panel requiring Chanjing (Digital Human, Voice, account)
- Click login to start OAuth CLI Web Login
- User completes browser authorization
- Re-check auth status, then continue workflow
If preview is unavailable:
Fall back to CLI-only guidance:
npx framevideo auth login
Then continue workflow.
What NOT to do:
- ❌ Stop at env var guidance if preview is available
- ❌ Print or save tokens outside credential store
- ❌ Ask user to manually edit
~/.chanjing/credentials - ❌ Use deprecated
app_id,secret_key, orCHANJING_OPENAPI_ACCESS_TOKEN
Studio Integration
Studio provides auth status and login UI via plugin routes.
Auth Status Endpoint
GET /api/projects/:id/chanjing/auth/status
Returns:
{
"authenticated": true,
"user": {
"id": "...",
"name": "..."
}
}
Use this to poll auth state after guiding user to Studio login.
Login Button
Available in:
- Digital Human panel (Studio → Digital Human → Login)
- Voice panel (Studio → Voice → Login)
- Account settings (Studio → Settings → Chanjing Account)
Clicking any login button triggers the same OAuth CLI Web Login flow.
Troubleshooting
"Not authenticated" error
Check:
npx framevideo auth status
Fix:
npx framevideo auth login
Token expired
The client auto-refreshes tokens. If refresh fails:
# Clear credentials and re-login
rm ~/.chanjing/credentials
npx framevideo auth login
"Invalid token" or 401 errors
Credential store may be corrupted:
# Inspect (redacted output)
npx framevideo auth status --json
# Clear and re-login
rm ~/.chanjing/credentials
npx framevideo auth login
CI/CD auth fails
- Verify
CHANJING_REFRESH_TOKENis set - Check token hasn't expired (refresh tokens typically valid 30-90 days)
- Obtain fresh refresh token from interactive session
Integration with Other Skills
chanjing-digital-human
Uses this auth for:
- Listing digital humans and voices
- Submitting website-project synthesis
- Polling task status
- Downloading generated videos
chanjing-media (planned)
Uses this auth for:
- Background music list and download
- Sound effects list and download
framevideo-media
Does NOT use this auth. Local Kokoro TTS is offline and credential-free.
Security Best Practices
- Never print tokens - Not in logs, not in error messages, not in agent responses
- Use credential store APIs - Don't read
~/.chanjing/credentialsdirectly - No tokens in Git - Add credential files to
.gitignore - Secure CI secrets - Use secret management for
CHANJING_REFRESH_TOKEN - Don't copy standalone scripts - Reuse shared auth client, don't duplicate
Validation
After authentication:
# Should show "authenticated: true"
npx framevideo auth status
# Should list available resources
npx framevideo chanjing music categories --json
If both succeed, authentication is working correctly.
References
- Auth store implementation:
packages/cli/src/auth/store.ts - Plugin API client:
packages/cli/src/tts/chanjingOpenapi.ts - Studio auth routes: See
chanjing-digital-humanskill,references/studio-routes.md