- eBay Developer account
- eBay application created (Client ID and Secret)
- MCP server installed
Why OAuth 2.0?
OAuth 2.0 user tokens unlock the full potential of the eBay MCP Server:Full API Access
High Rate Limits
Automatic Refresh
User-specific Data
OAuth Flow Overview
Understanding the OAuth 2.0 authorization flow:User Authorization Request
Authorization Code
Token Exchange
API Access
Token Refresh
Setup Method 1: Interactive Wizard (Recommended)
The easiest way to set up OAuth - a beautiful CLI wizard that handles everything:Step 1: Run the Setup Wizard
Step 2: Choose Your Environment
Select your eBay environment:- Sandbox: For testing and development (recommended initially)
- Production: For live seller operations
Step 3: Enter Your Credentials
The wizard will prompt you for:Step 4: Authorize Your Application
The wizard will:- Generate an authorization URL
- Open your browser automatically (or display the URL if auto-open fails)
- You log in to eBay with your seller account
- You approve the application by clicking “Agree”
- eBay redirects back to the callback URL
Step 5: Token Exchange
The wizard automatically:- Extracts the authorization code from the redirect
- Exchanges it for access and refresh tokens
- Saves tokens securely to your
.envfile
Setup Method 2: Automatic Setup
If you prefer to edit the.env file first:
Create .env File
.env with your credentials:Run Automatic Setup
Authorize in Browser
- Log in with your eBay seller account
- Review the requested scopes
- Click “Agree” to authorize
Verification
- Captures the authorization code
- Exchanges it for tokens
- Updates your
.envfile - Confirms successful setup
Setup Method 3: Manual OAuth Flow
For advanced users who want complete control:Generate Authorization URL
Authorize in Browser
- Paste the URL into your browser
- Log in with your eBay seller account
- Review the scopes and click “Agree”
- After authorization, eBay redirects to:
- Copy the entire redirect URL from your browser address bar
Extract Authorization Code
code= (everything before &expires_in):Exchange Code for Tokens
.env.Verify Setup
.env file - it should now contain:Configuring eBay Developer Portal
Before running the OAuth flow, ensure your application is properly configured in the eBay Developer Portal.Required OAuth Settings
Navigate to Application Settings
- Sign in to eBay Developer Portal
- Go to My Account → Application Keys
- Select your application (Sandbox or Production)
Add Redirect URI
- Click Add OAuth Redirect URI
- Enter:
http://localhost:3000/callback - Click Save
http://localhost:3000/callback(default)https://yourdomain.com/oauth/callback(production)http://127.0.0.1:3000/callback(alternative localhost)
Verify OAuth Scopes
https://api.ebay.com/oauth/api_scope/sell.inventoryhttps://api.ebay.com/oauth/api_scope/sell.fulfillmenthttps://api.ebay.com/oauth/api_scope/sell.accounthttps://api.ebay.com/oauth/api_scope/sell.marketinghttps://api.ebay.com/oauth/api_scope/sell.analytics.readonlyhttps://api.ebay.com/oauth/api_scope/sell.account.readonly
Note Your Credentials
- App ID (Client ID)
- Cert ID (Client Secret)
- App ID (Client ID)
- Cert ID (Client Secret)
Understanding OAuth Scopes
OAuth scopes define what your application can access. The eBay MCP Server requires these scopes:sell.inventory - Manage Inventory
sell.inventory - Manage Inventory
- Create, read, update, delete inventory items
- Manage offers and listings
- Handle inventory locations
- Bulk operations on inventory
sell.fulfillment - Order Management
sell.fulfillment - Order Management
- View and manage orders
- Handle shipping and fulfillment
- Process returns and cancellations
- Update tracking information
sell.account - Account Management
sell.account - Account Management
- Manage fulfillment policies
- Configure payment policies
- Set return policies
- Manage selling programs
sell.marketing - Marketing & Promotions
sell.marketing - Marketing & Promotions
- Create promoted listings campaigns
- Manage item promotions
- View campaign analytics
- Optimize marketing spend
sell.analytics.readonly - Analytics Access
sell.analytics.readonly - Analytics Access
- View traffic reports
- Access seller analytics
- Generate performance insights
- Track metrics
sell.account.readonly - Account Info (Read)
sell.account.readonly - Account Info (Read)
- Read account settings
- View policy information
- Check program enrollment
- Access metadata
Testing Your OAuth Setup
After completing OAuth setup, verify everything works:1. Check Environment Variables
Verify your.env file contains all required variables:
2. Validate Configuration
Run the validation script:- ✅ All required variables present
- ✅ Credentials format is correct
- ✅ Tokens are valid and not expired
- ✅ API connectivity works
3. Start the MCP Server
Token Lifecycle
Understanding how tokens work helps you troubleshoot issues:Access Token
Lifetime: ~2 hours (7,200 seconds) Purpose: Used for API calls Automatic refresh: Yes, when expiredRefresh Token
Lifetime: 18 months (540 days) Purpose: Obtain new access tokens Renewal: Automatically renewed when usedToken Expiry
Troubleshooting OAuth Setup
Common Issues and Solutions
Redirect URI Mismatch Error
Redirect URI Mismatch Error
.env doesn’t match what’s configured in eBay Developer Portal.Solution:- Go to eBay Developer Portal
- Navigate to your application’s OAuth settings
- Ensure
http://localhost:3000/callbackis in the OAuth Redirect URIs list - Check for typos (http vs https, trailing slashes, etc.)
- Update
.envto match exactly
Invalid Client ID/Secret
Invalid Client ID/Secret
- Verify credentials in eBay Developer Portal
- Ensure you’re using the correct environment (Sandbox vs Production)
- Check for copy-paste errors or extra spaces
- Regenerate credentials if necessary
Authorization Code Expired
Authorization Code Expired
Browser Doesn't Open Automatically
Browser Doesn't Open Automatically
- Copy the authorization URL from the terminal
- Manually paste it into your browser
- Complete the authorization
- The wizard will detect the callback automatically
Invalid Scope Error
Invalid Scope Error
- Go to eBay Developer Portal
- Check your application’s scope settings
- Ensure all required eBay Sell APIs scopes are enabled
- Save changes and retry authorization
Tokens Not Refreshing
Tokens Not Refreshing
- Check
EBAY_USER_REFRESH_TOKENexists in.env - Verify token format is correct (starts with
v^1.1#) - Re-run
npm run setupto regenerate fresh tokens - Check server logs for specific refresh errors
Advanced OAuth Configuration
Custom Redirect URI
If you need to use a different redirect URI:Update eBay Developer Portal
Update .env
Handle the Callback
Production OAuth Setup
When moving to production:Create Production Application
- Switch to Production tab
- Create new application (or use existing)
- Configure OAuth redirect URIs
- Note production credentials
Update .env for Production
Run OAuth Flow for Production
Verify Production Setup
Security Best Practices
Never Share Tokens
Never Share Tokens
Secure Your Redirect URI
Secure Your Redirect URI
- Use HTTPS redirect URIs
- Validate the
stateparameter (anti-CSRF) - Implement rate limiting on callback endpoint
- Log all authorization attempts
- Monitor for suspicious activity
Monitor Token Usage
Monitor Token Usage
- Review API usage in eBay Developer Portal
- Check for unexpected token refreshes
- Monitor rate limit consumption
- Alert on anomalous patterns
Rotate Tokens Periodically
Rotate Tokens Periodically
- Re-authorize every 6-12 months
- Immediately revoke if compromised
- Test new tokens before switching
- Keep audit trail of rotations