Getting Your Clerk Token - Step by Step Guide
π Your Clerk Configuration
Based on the API response, your Clerk app (poetic-primate-48.clerk.accounts.dev) is configured to only support:
- β
Google OAuth (
oauth_google) - β
Ticket-based authentication (
ticket) - β Email/Password authentication (not enabled)
π― Recommended Method: Browser Console
This is the easiest and most reliable method:
Step 1: Sign in via Google OAuth
- Open your browser
- Go to:
https://poetic-primate-48.clerk.accounts.dev - Click "Sign in with Google"
- Complete the Google OAuth flow
Step 2: Get the Token
- Once signed in, open Developer Tools (Press F12)
- Go to the Console tab
- Paste this command and press Enter:
window.Clerk.session.getToken().then(token => console.log('TOKEN:', token)) - Copy the token (the long string after "TOKEN:")
Step 3: Test Your API
python test_current_api.py http://localhost:8000/api/v1 YOUR_TOKEN_HERE
π Quick Start Scripts
Option A: Use the OAuth Helper
python get_clerk_token_oauth.py
Choose option 2 (Manual browser method)
Option B: Use the Simple Helper
python get_token_simple.py
Choose option 1 (Browser Console Method)
π Complete Example
Open browser and sign in:
- Go to: https://poetic-primate-48.clerk.accounts.dev
- Sign in with Google
Get token in console:
window.Clerk.session.getToken().then(token => console.log('TOKEN:', token))Copy the token (looks like:
eyJhbGciOiJSUzI1NiIsImtpZCI6Imluc18...)Test your API:
python test_current_api.py http://localhost:8000/api/v1 eyJhbGciOiJSUzI1NiIsImtpZCI6Imluc18...
π§ Why Email/Password Didn't Work
The API response showed:
{
"status": "needs_identifier",
"supported_first_factors": [
{"strategy": "ticket"},
{"strategy": "oauth_google"}
]
}
This means your Clerk app is configured to only allow:
- Google OAuth sign-in
- Ticket-based authentication (for programmatic access)
Email/password authentication is not enabled in your Clerk dashboard.
π― Next Steps
Once you have your token:
Test basic connectivity:
python test_current_api.py http://localhost:8000/api/v1 YOUR_TOKENTest video generation:
python test_video_generation.py --base-url http://localhost:8000/api/v1 --token YOUR_TOKEN --quickRun comprehensive tests:
python test_video_generation.py --base-url http://localhost:8000/api/v1 --token YOUR_TOKEN
π‘ Pro Tips
- Tokens expire: You may need to get a fresh token periodically
- Save your token: The scripts will save it to
auth_token.txtfor reuse - Use the browser method: It's the most reliable approach
- Check token format: Valid tokens start with
eyJ
π Troubleshooting
If the browser console method doesn't work:
- Make sure you're signed in to your app
- Check that
window.Clerkexists by typing it in console - Try refreshing the page after signing in
- Make sure you're on the correct domain
If you get "Clerk not found" errors:
- Make sure you're on a page where Clerk is loaded
- Try going to the main app page after signing in
- Check the Network tab for any Clerk-related requests