Authentication
Vision.meme uses wallet-based authentication with JWT (JSON Web Tokens) to secure API endpoints. This ensures that only wallet owners can manage their tokens and settings.
Overview
The authentication flow uses a challenge-verify mechanism:
Request a challenge message from the API
Sign the challenge with your Solana wallet
Submit the signature to receive a JWT token
Use the JWT token for authenticated requests
Benefits:
✅ No passwords needed
✅ Cryptographically secure
✅ Wallet ownership verified
✅ Standard JWT tokens
✅ 7-day token lifetime
Authentication Flow
Step 1: Request Challenge
Request a unique challenge message for your wallet.
Endpoint: POST /auth/challenge
Request:
json
Response:
json
Details:
Challenge expires in 5 minutes
Challenge includes timestamp for uniqueness
Use the exact challenge message for signing
Step 2: Sign Challenge
Sign the challenge message with your Solana wallet's private key.
Using @solana/web3.js:
javascript
Using Phantom Wallet:
javascript
Using Solflare:
javascript
Step 3: Verify Signature
Submit the signed challenge to receive your JWT token.
Endpoint: POST /auth/verify
Request:
json
Response:
json
Details:
JWT token expires in 7 days
Token is wallet-specific
Store token securely for future requests
Step 4: Use Token
Include the JWT token in the Authorization header for authenticated requests.
Header Format:
http
Example Request:
bash
Complete Example
JavaScript/TypeScript
javascript
Python
python
Token Management
Storing Tokens
Client-side (Browser):
javascript
Server-side (Node.js):
javascript
Best Practices:
✅ Never expose tokens in client-side code repositories
✅ Use environment variables for server-side applications
✅ Clear tokens on logout
✅ Use secure storage for sensitive applications
⚠️ Don't commit tokens to git
Checking Token Expiration
javascript
Auto-Refresh Pattern
javascript
Security Best Practices
Never Share Private Keys
javascript
Validate Wallet Address
javascript
Handle Authentication Errors
javascript
Implement Retry Logic
javascript
Common Errors
Challenge Expired
Error:
json
Solution:
Request a new challenge
Complete signing within 5 minutes
Don't cache challenges
Invalid Signature
Error:
json
Solutions:
Ensure you're signing the exact challenge message
Use the correct signing method for your wallet
Verify wallet address matches the one used for challenge
Invalid Token
Error:
json
Solutions:
Check if token has expired (7-day lifetime)
Re-authenticate to get a new token
Verify token is correctly formatted in Authorization header
Wallet Not Connected
Error:
javascript
Solution:
javascript
Rate Limits
Authentication endpoints have specific rate limits:
POST /auth/challenge
20 requests per minute
POST /auth/verify
20 requests per minute
Exceeded Rate Limit:
json
Wait for the retryAfter seconds before trying again.
Testing Authentication
Test on Devnet
javascript
Verify Token Payload
javascript
Next Steps
Rate Limits - Understand API rate limiting
Token Endpoints - Start creating tokens
Code Examples - More integration examples
Need Help?
💬 Discord Community
📱 Telegram Support
© 2025 Vision.meme. All rights reserved.
Last updated