Authentication
T3Router uses your browser cookies to authenticate with t3.chat. This guide will walk you through extracting these credentials and setting them up securely.How Authentication Works
T3Router authenticates by:- Using your browser’s cookie string to maintain your session
- Including your
convex-session-idto identify your active session - Automatically refreshing the
wos-sessioncookie when needed
Getting Your Credentials
Open t3.chat in Your Browser
Navigate to t3.chat and make sure you’re logged in to your paid account.
Open Developer Tools
- Chrome / Edge / Brave
- Firefox
- Safari
- Press F12, or
- Press Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (Mac), or
- Right-click anywhere and select Inspect
Navigate to Storage
- Chrome / Edge / Brave
- Firefox
- Safari
- Click the Application tab in Developer Tools
- In the left sidebar, expand Cookies
- Click on
https://t3.chat
Copy convex-session-id
In the cookies table:
- Find the row with Name
convex-session-id - Copy the Value column (a long string of characters)
- Save it temporarily - you’ll need this in a moment
The
convex-session-id identifies your active session on t3.chat. It looks something like: j1h9z3y8x7w6v5u4t3s2r1q0p9o8n7m6Setting Up Your Environment
Create .env File
In your project root directory, create a file named Important formatting notes:
.env:.env
- Put your actual values inside the quotes
- The
COOKIESvalue should be the entire cookie string from step 5 - The
CONVEX_SESSION_IDvalue is just the session ID from step 4 (without extra quotes) - Do not include the
format!()wrapper - that’s done in your Rust code
Add .env to .gitignore
Critical security step: Never commit credentials to version control.Add to your
.gitignore:.gitignore
Example .env File
Here’s what a properly formatted.env file looks like:
.env
Security Best Practices
Never Commit Credentials
Never Commit Credentials
- Always use
.envfiles for credentials - Always add
.envto.gitignore - Use
.env.example(with placeholder values) to document required variables - Never hardcode credentials in your source code
Rotate Credentials Regularly
Rotate Credentials Regularly
Cookies can expire or be invalidated. When you notice authentication failures:
- Log out of t3.chat in your browser
- Log back in
- Extract fresh credentials using the steps above
- Update your
.envfile
Use Environment-Specific Configuration
Use Environment-Specific Configuration
For production deployments:
- Use your platform’s secret management (AWS Secrets Manager, etc.)
- Never store credentials in container images
- Use environment variables injected at runtime
- Consider using temporary credentials when possible
Limit Exposure
Limit Exposure
- Only store credentials on machines you trust
- Don’t share your
.envfile - Use restrictive file permissions:
chmod 600 .env - Consider using a password manager to store backup credentials
How the Client Uses Your Credentials
When you create a client, here’s what happens:Client struct stores your credentials and uses them to:
- Authenticate requests: Your cookie string is sent with every API call
- Maintain sessions: The
convex-session-ididentifies your active session - Auto-refresh: The
wos-sessioncookie is automatically updated viarefresh_session()
src/t3/client.rs:32-58:
Troubleshooting
Error: COOKIES not set
Error: COOKIES not set
Authentication Failures
Authentication Failures
Your cookies may have expired:
- Extract fresh credentials from your browser
- Make sure you’re logged into a paid t3.chat account
- Verify the cookie string is complete and properly formatted
- Check that
convex-session-idmatches what’s in your browser
Session Refresh Issues
Session Refresh Issues
The library automatically refreshes your session, but if you see issues:
- The
wos-sessioncookie may need manual refresh - Try calling
client.refresh_session().await?explicitly - Extract fresh cookies from your browser if problems persist
Next Steps
Quickstart
Now that you understand authentication, complete the quickstart guide.
Client Reference
Learn about all the methods available on the Client struct.