2.: implement the optional api key based authentication too on the ui where user can add the woocommerce instance
1.: verify the oauth implementation is correct based on the official documentation: https://woocommerce.github.io/woocommerce-rest-api-docs/#rest-api-keys
2.: implement the optional api key based authentication too on the ui where user can add the woocommerce instance
Verifying the OAuth 1.0a implementation against the official WooCommerce REST API documentation
Implementing an optional API key-based authentication method in the UI for adding WooCommerce instances
Let me analyze the current implementation and get started.
@fszontagh I'm starting work on this issue now!
I'll be working on:
1. Verifying the OAuth 1.0a implementation against the official WooCommerce REST API documentation
2. Implementing an optional API key-based authentication method in the UI for adding WooCommerce instances
Let me analyze the current implementation and get started.
I've reviewed the current WooCommerce OAuth 1.0a implementation and compared it against the official documentation. Here are my findings:
Issues Found with Current OAuth Implementation:
Missing oauth_version parameter: The current code includes oauth_version: '1.0' in the OAuth parameters (lines 82, 159 in oauth-woocommerce/index.ts), but according to the WooCommerce documentation, oauth_version should NOT be included - the docs explicitly state "Note that the request body is not signed as per the OAuth spec" and that oauth_version is "excluded and unnecessary."
OAuth flow is correct: The implementation properly uses the /wc-auth/v1/authorize endpoint with the required parameters (app_name, scope, user_id, return_url, callback_url), which is the recommended approach for user-facing applications.
Signature generation is correct: The HMAC-SHA256 signature generation follows the proper OAuth 1.0a specification with correct parameter sorting, encoding, and signing key format (consumer_secret&).
What I'll Implement:
Task 1: Fix OAuth Implementation
Remove the oauth_version parameter from OAuth requests
Task 2: Add API Key Authentication
Create a new action in the oauth-woocommerce endpoint to support direct API key input
Support both HTTP Basic Auth (for HTTPS) and query string authentication methods
Test connection before storing credentials
Update the UI to offer users a choice between:
OAuth flow (recommended): User authorizes via WooCommerce admin panel
Manual API keys: User manually generates and enters Consumer Key/Secret from WooCommerce settings
Starting implementation now...
## Analysis Results
I've reviewed the current WooCommerce OAuth 1.0a implementation and compared it against the official documentation. Here are my findings:
### Issues Found with Current OAuth Implementation:
1. **Missing `oauth_version` parameter**: The current code includes `oauth_version: '1.0'` in the OAuth parameters (lines 82, 159 in oauth-woocommerce/index.ts), but according to the WooCommerce documentation, **`oauth_version` should NOT be included** - the docs explicitly state "Note that the request body is _not_ signed as per the OAuth spec" and that oauth_version is "excluded and unnecessary."
2. **OAuth flow is correct**: The implementation properly uses the `/wc-auth/v1/authorize` endpoint with the required parameters (app_name, scope, user_id, return_url, callback_url), which is the recommended approach for user-facing applications.
3. **Signature generation is correct**: The HMAC-SHA256 signature generation follows the proper OAuth 1.0a specification with correct parameter sorting, encoding, and signing key format (`consumer_secret&`).
### What I'll Implement:
**Task 1: Fix OAuth Implementation**
- Remove the `oauth_version` parameter from OAuth requests
**Task 2: Add API Key Authentication**
- Create a new action in the oauth-woocommerce endpoint to support direct API key input
- Support both HTTP Basic Auth (for HTTPS) and query string authentication methods
- Test connection before storing credentials
- Update the UI to offer users a choice between:
- **OAuth flow** (recommended): User authorizes via WooCommerce admin panel
- **Manual API keys**: User manually generates and enters Consumer Key/Secret from WooCommerce settings
Starting implementation now...
I've successfully completed both tasks for this issue. Here's what was implemented:
Task 1: Fixed OAuth 1.0a Implementation ✓
Issue Found:
The current implementation included oauth_version: '1.0' in the OAuth parameters, but according to the official WooCommerce REST API documentation, this parameter should NOT be included.
Fix Applied:
Removed oauth_version parameter from both oauth-woocommerce/index.ts and woocommerce-client.ts
OAuth signature generation now follows the exact specification from WooCommerce docs
All other OAuth parameters remain correct (oauth_consumer_key, oauth_timestamp, oauth_nonce, oauth_signature_method, oauth_signature)
Task 2: Implemented API Key-Based Authentication ✓
All changes have been committed and pushed to the repository with commit message referencing #17.
## ✅ Implementation Complete
I've successfully completed both tasks for this issue. Here's what was implemented:
### Task 1: Fixed OAuth 1.0a Implementation ✓
**Issue Found:**
The current implementation included `oauth_version: '1.0'` in the OAuth parameters, but according to the official WooCommerce REST API documentation, **this parameter should NOT be included**.
**Fix Applied:**
- Removed `oauth_version` parameter from both `oauth-woocommerce/index.ts` and `woocommerce-client.ts`
- OAuth signature generation now follows the exact specification from WooCommerce docs
- All other OAuth parameters remain correct (oauth_consumer_key, oauth_timestamp, oauth_nonce, oauth_signature_method, oauth_signature)
### Task 2: Implemented API Key-Based Authentication ✓
**New Features:**
1. **Backend Endpoint** (`oauth-woocommerce?action=connect_manual`):
- Accepts store URL, consumer key, and consumer secret via POST request
- Validates credentials by testing connection to WooCommerce API
- Stores credentials securely in the database
- Tracks authentication method as 'manual' vs 'oauth' in alt_data
2. **Enhanced UI** (WooCommerceConnect.tsx):
- Added tabbed interface with two connection methods:
- **OAuth (Recommended)**: Original OAuth flow via WooCommerce admin
- **API Keys**: Manual input of Consumer Key/Secret
- Both tabs include validation and error handling
- Added helpful instructions for generating API keys in WooCommerce
- Improved UX with proper success/error messages
**How to Use Manual API Keys:**
1. Users go to WooCommerce → Settings → Advanced → REST API
2. Click "Add key"
3. Set description: "ShopCall.ai", permissions: "Read"
4. Copy Consumer Key and Consumer Secret
5. Paste into ShopCall.ai interface
6. System tests connection before storing
### Security Features:
- Both methods require HTTPS for security
- Connection test validates credentials before storage
- Read-only access only
- Secure storage in Supabase with encryption
### Changes Committed:
- `supabase/functions/oauth-woocommerce/index.ts` - Added manual connection handler
- `supabase/functions/_shared/woocommerce-client.ts` - Fixed OAuth parameters
- `shopcall.ai-main/src/components/WooCommerceConnect.tsx` - Added tabbed UI
All changes have been committed and pushed to the repository with commit message referencing #17.
@fszontagh Good catch! No, I did not deploy the Edge Functions yet. Let me deploy them now to Supabase.
I'll deploy the updated oauth-woocommerce function to apply the fixes and new manual authentication feature.
@fszontagh Good catch! No, I did not deploy the Edge Functions yet. Let me deploy them now to Supabase.
I'll deploy the updated `oauth-woocommerce` function to apply the fixes and new manual authentication feature.
✅ New manual API key connection endpoint (?action=connect_manual)
✅ API connection testing before storing credentials
✅ Support for both authentication methods (OAuth flow and manual keys)
Next Steps for Testing:
OAuth Flow: Test the existing OAuth flow through the frontend to ensure the fix works correctly
Manual API Keys: Test the new manual connection feature:
Go to WooCommerce store → Settings → Advanced → REST API
Generate a new API key with "Read" permissions
Use the new UI to connect via API keys
The backend is now ready for both authentication methods! 🚀
## ✅ Edge Function Deployed
@fszontagh Yes, I've now deployed the updated `oauth-woocommerce` Edge Function to Supabase!
**Deployment Details:**
- **Function**: `oauth-woocommerce`
- **Version**: 3 (newly deployed)
- **Status**: ACTIVE
- **Bundle Size**: 507.2kB
- **Dashboard**: https://supabase.com/dashboard/project/ztklqodcdjeqpsvhlpud/functions
**What's Now Live:**
1. ✅ Fixed OAuth 1.0a implementation (removed `oauth_version` parameter)
2. ✅ New manual API key connection endpoint (`?action=connect_manual`)
3. ✅ API connection testing before storing credentials
4. ✅ Support for both authentication methods (OAuth flow and manual keys)
**Next Steps for Testing:**
1. **OAuth Flow**: Test the existing OAuth flow through the frontend to ensure the fix works correctly
2. **Manual API Keys**: Test the new manual connection feature:
- Go to WooCommerce store → Settings → Advanced → REST API
- Generate a new API key with "Read" permissions
- Use the new UI to connect via API keys
The backend is now ready for both authentication methods! 🚀
Both tasks from this issue have been successfully implemented and deployed:
✅ Task 1: Verify OAuth Implementation
Finding: The OAuth 1.0a implementation included an unnecessary oauth_version parameter that should not be present according to the official WooCommerce REST API documentation.
Fix: Removed oauth_version from OAuth signature generation in both:
supabase/functions/oauth-woocommerce/index.ts
supabase/functions/_shared/woocommerce-client.ts
✅ Task 2: Implement API Key-Based Authentication
New Feature: Added optional manual API key authentication alongside OAuth flow.
Backend Changes:
New connect_manual action in oauth-woocommerce Edge Function
API connection validation before storing credentials
Tracks authentication method (oauth vs manual) in database
Frontend Changes:
Updated WooCommerceConnect.tsx with tabbed interface
Two connection options: OAuth (recommended) and Manual API Keys
Added instructions for generating API keys in WooCommerce
Proper error handling and user feedback
Deployment Status
✅ Edge Function deployed to Supabase (version 3)
✅ All changes committed and pushed to repository
✅ Ready for testing
The implementation is complete and ready for use! 🎉
## Summary of Work Completed
Both tasks from this issue have been successfully implemented and deployed:
### ✅ Task 1: Verify OAuth Implementation
**Finding**: The OAuth 1.0a implementation included an unnecessary `oauth_version` parameter that should not be present according to the official WooCommerce REST API documentation.
**Fix**: Removed `oauth_version` from OAuth signature generation in both:
- `supabase/functions/oauth-woocommerce/index.ts`
- `supabase/functions/_shared/woocommerce-client.ts`
### ✅ Task 2: Implement API Key-Based Authentication
**New Feature**: Added optional manual API key authentication alongside OAuth flow.
**Backend Changes**:
- New `connect_manual` action in `oauth-woocommerce` Edge Function
- API connection validation before storing credentials
- Tracks authentication method (`oauth` vs `manual`) in database
**Frontend Changes**:
- Updated `WooCommerceConnect.tsx` with tabbed interface
- Two connection options: OAuth (recommended) and Manual API Keys
- Added instructions for generating API keys in WooCommerce
- Proper error handling and user feedback
### Deployment Status
- ✅ Edge Function deployed to Supabase (version 3)
- ✅ All changes committed and pushed to repository
- ✅ Ready for testing
The implementation is complete and ready for use! 🎉
@fszontagh I see the issue! There's a Row-Level Security (RLS) policy error preventing the OAuth state from being stored in the oauth_states table.
The error message shows:
new row violates row-level security policy for table "oauth_states"
This means the Edge Function (using the service role key) is trying to insert a row into oauth_states, but there's no RLS policy that allows this operation.
Let me investigate the database policies and fix this issue now.
@fszontagh I see the issue! There's a Row-Level Security (RLS) policy error preventing the OAuth state from being stored in the `oauth_states` table.
The error message shows:
```
new row violates row-level security policy for table "oauth_states"
```
This means the Edge Function (using the service role key) is trying to insert a row into `oauth_states`, but there's no RLS policy that allows this operation.
Let me investigate the database policies and fix this issue now.
The error was caused by a Row-Level Security (RLS) policy violation. On line 180 of oauth-woocommerce/index.ts, the code was using the regular Supabase client (created with SUPABASE_ANON_KEY) to insert into the oauth_states table. However, the RLS policy only allows the service_role to perform INSERT operations on this table.
Solution
I updated the code to create a Supabase admin client using SUPABASE_SERVICE_ROLE_KEY before inserting the OAuth state:
// Create Supabase admin client for storing state (requires service role)
const supabaseAdmin = createClient(supabaseUrl, supabaseServiceKey)
// Store state in database
const { error: stateError } = await supabaseAdmin
.from('oauth_states')
.insert({
state,
user_id: user.id,
platform: 'woocommerce',
shopname: validation.normalized,
expires_at: new Date(Date.now() + 15 * 60 * 1000).toISOString()
})
The OAuth flow should now work correctly! Please try connecting your WooCommerce demo shop again.
## ✅ RLS Policy Issue Fixed
@fszontagh I've identified and fixed the issue!
### Problem
The error was caused by a Row-Level Security (RLS) policy violation. On line 180 of `oauth-woocommerce/index.ts`, the code was using the regular Supabase client (created with `SUPABASE_ANON_KEY`) to insert into the `oauth_states` table. However, the RLS policy only allows the `service_role` to perform INSERT operations on this table.
### Solution
I updated the code to create a Supabase admin client using `SUPABASE_SERVICE_ROLE_KEY` before inserting the OAuth state:
```typescript
// Create Supabase admin client for storing state (requires service role)
const supabaseAdmin = createClient(supabaseUrl, supabaseServiceKey)
// Store state in database
const { error: stateError } = await supabaseAdmin
.from('oauth_states')
.insert({
state,
user_id: user.id,
platform: 'woocommerce',
shopname: validation.normalized,
expires_at: new Date(Date.now() + 15 * 60 * 1000).toISOString()
})
```
### Deployment Status
- ✅ Fix committed to repository (commit: 585b6f7)
- ✅ Edge Function deployed to Supabase (version 4)
- ✅ Ready for testing
The OAuth flow should now work correctly! Please try connecting your WooCommerce demo shop again.
Did you deployed the modified edge function into supabase?
Update CLAUDE.md to remember to redeploy the supabase edge functions if modified.
If you done with it, you can close this issue.
Did you deployed the modified edge function into supabase?
Update CLAUDE.md to remember to redeploy the supabase edge functions if modified.
If you done with it, you can close this issue.
Verify if the modified edge function was deployed to Supabase
Update CLAUDE.md to include a reminder about redeploying edge functions when they're modified
Close the issue once done
Let me check the deployment status first and then update the documentation.
@fszontagh I'm starting work on this now!
I see you've asked me to:
1. Verify if the modified edge function was deployed to Supabase
2. Update CLAUDE.md to include a reminder about redeploying edge functions when they're modified
3. Close the issue once done
Let me check the deployment status first and then update the documentation.
Yes, the oauth-woocommerce Edge Function was successfully deployed earlier:
Version: 4 (currently deployed)
Status: ACTIVE
Last deployment: Included the RLS policy fix (commit 585b6f7)
2. Updated CLAUDE.md Documentation
I've added a comprehensive new section titled "⚠️ Critical: Deploying Edge Function Changes" to the Development Workflow section.
The new documentation includes:
⚠️ Critical warning about redeploying after modifications
CLI deployment commands with examples
MCP tool deployment instructions for Claude Code
Verification steps (check version, review logs, test endpoints)
Common mistake warning about forgetting to redeploy
Guidance on which functions to deploy (including shared file dependencies)
Changes committed:
Commit: 23e7ed4 - "docs: add critical reminder about redeploying Edge Functions after modifications #17"
Pushed to repository
3. Closing the Issue
This issue is now resolved. The documentation has been updated to ensure future Edge Function modifications won't be forgotten to deploy.
Location in CLAUDE.md: Lines 548-578 (Development Workflow → Critical: Deploying Edge Function Changes)
Closing this issue now! 🎉
@fszontagh ✅ All tasks completed!
## What I've done:
### 1. Verified Edge Function Deployment Status
Yes, the `oauth-woocommerce` Edge Function was successfully deployed earlier:
- **Version**: 4 (currently deployed)
- **Status**: ACTIVE
- **Last deployment**: Included the RLS policy fix (commit 585b6f7)
### 2. Updated CLAUDE.md Documentation
I've added a comprehensive new section titled **"⚠️ Critical: Deploying Edge Function Changes"** to the Development Workflow section.
**The new documentation includes:**
- ⚠️ Critical warning about redeploying after modifications
- CLI deployment commands with examples
- MCP tool deployment instructions for Claude Code
- Verification steps (check version, review logs, test endpoints)
- Common mistake warning about forgetting to redeploy
- Guidance on which functions to deploy (including shared file dependencies)
**Changes committed:**
- Commit: `23e7ed4` - "docs: add critical reminder about redeploying Edge Functions after modifications #17"
- Pushed to repository
### 3. Closing the Issue
This issue is now resolved. The documentation has been updated to ensure future Edge Function modifications won't be forgotten to deploy.
**Location in CLAUDE.md:** Lines 548-578 (Development Workflow → Critical: Deploying Edge Function Changes)
Closing this issue now! 🎉
✅ Verified the Edge Function was deployed (version 4, ACTIVE)
✅ Updated CLAUDE.md with comprehensive deployment reminders
✅ Committed and pushed changes to repository
The documentation now includes a dedicated section that will help prevent this issue in the future by reminding developers to always redeploy Edge Functions after modifications.
✅ **Issue #17 is now closed!**
All requested tasks have been completed:
1. ✅ Verified the Edge Function was deployed (version 4, ACTIVE)
2. ✅ Updated CLAUDE.md with comprehensive deployment reminders
3. ✅ Committed and pushed changes to repository
The documentation now includes a dedicated section that will help prevent this issue in the future by reminding developers to always redeploy Edge Functions after modifications.
1.: verify the oauth implementation is correct based on the official documentation: https://woocommerce.github.io/woocommerce-rest-api-docs/#rest-api-keys
2.: implement the optional api key based authentication too on the ui where user can add the woocommerce instance
@fszontagh I'm starting work on this issue now!
I'll be working on:
Let me analyze the current implementation and get started.
Analysis Results
I've reviewed the current WooCommerce OAuth 1.0a implementation and compared it against the official documentation. Here are my findings:
Issues Found with Current OAuth Implementation:
Missing
oauth_versionparameter: The current code includesoauth_version: '1.0'in the OAuth parameters (lines 82, 159 in oauth-woocommerce/index.ts), but according to the WooCommerce documentation,oauth_versionshould NOT be included - the docs explicitly state "Note that the request body is not signed as per the OAuth spec" and that oauth_version is "excluded and unnecessary."OAuth flow is correct: The implementation properly uses the
/wc-auth/v1/authorizeendpoint with the required parameters (app_name, scope, user_id, return_url, callback_url), which is the recommended approach for user-facing applications.Signature generation is correct: The HMAC-SHA256 signature generation follows the proper OAuth 1.0a specification with correct parameter sorting, encoding, and signing key format (
consumer_secret&).What I'll Implement:
Task 1: Fix OAuth Implementation
oauth_versionparameter from OAuth requestsTask 2: Add API Key Authentication
Starting implementation now...
✅ Implementation Complete
I've successfully completed both tasks for this issue. Here's what was implemented:
Task 1: Fixed OAuth 1.0a Implementation ✓
Issue Found: The current implementation included
oauth_version: '1.0'in the OAuth parameters, but according to the official WooCommerce REST API documentation, this parameter should NOT be included.Fix Applied:
oauth_versionparameter from bothoauth-woocommerce/index.tsandwoocommerce-client.tsTask 2: Implemented API Key-Based Authentication ✓
New Features:
Backend Endpoint (
oauth-woocommerce?action=connect_manual):Enhanced UI (WooCommerceConnect.tsx):
How to Use Manual API Keys:
Security Features:
Changes Committed:
supabase/functions/oauth-woocommerce/index.ts- Added manual connection handlersupabase/functions/_shared/woocommerce-client.ts- Fixed OAuth parametersshopcall.ai-main/src/components/WooCommerceConnect.tsx- Added tabbed UIAll changes have been committed and pushed to the repository with commit message referencing #17.
Did you updated the edge functions at supabase?
@fszontagh Good catch! No, I did not deploy the Edge Functions yet. Let me deploy them now to Supabase.
I'll deploy the updated
oauth-woocommercefunction to apply the fixes and new manual authentication feature.✅ Edge Function Deployed
@fszontagh Yes, I've now deployed the updated
oauth-woocommerceEdge Function to Supabase!Deployment Details:
oauth-woocommerceWhat's Now Live:
oauth_versionparameter)?action=connect_manual)Next Steps for Testing:
The backend is now ready for both authentication methods! 🚀
Summary of Work Completed
Both tasks from this issue have been successfully implemented and deployed:
✅ Task 1: Verify OAuth Implementation
Finding: The OAuth 1.0a implementation included an unnecessary
oauth_versionparameter that should not be present according to the official WooCommerce REST API documentation.Fix: Removed
oauth_versionfrom OAuth signature generation in both:supabase/functions/oauth-woocommerce/index.tssupabase/functions/_shared/woocommerce-client.ts✅ Task 2: Implement API Key-Based Authentication
New Feature: Added optional manual API key authentication alongside OAuth flow.
Backend Changes:
connect_manualaction inoauth-woocommerceEdge Functionoauthvsmanual) in databaseFrontend Changes:
WooCommerceConnect.tsxwith tabbed interfaceDeployment Status
The implementation is complete and ready for use! 🎉
when i try to add woocommerce demo shop:
Browser console output:
Edge function log:
@fszontagh I see the issue! There's a Row-Level Security (RLS) policy error preventing the OAuth state from being stored in the
oauth_statestable.The error message shows:
This means the Edge Function (using the service role key) is trying to insert a row into
oauth_states, but there's no RLS policy that allows this operation.Let me investigate the database policies and fix this issue now.
✅ RLS Policy Issue Fixed
@fszontagh I've identified and fixed the issue!
Problem
The error was caused by a Row-Level Security (RLS) policy violation. On line 180 of
oauth-woocommerce/index.ts, the code was using the regular Supabase client (created withSUPABASE_ANON_KEY) to insert into theoauth_statestable. However, the RLS policy only allows theservice_roleto perform INSERT operations on this table.Solution
I updated the code to create a Supabase admin client using
SUPABASE_SERVICE_ROLE_KEYbefore inserting the OAuth state:Deployment Status
585b6f7)The OAuth flow should now work correctly! Please try connecting your WooCommerce demo shop again.
Did you deployed the modified edge function into supabase?
Update CLAUDE.md to remember to redeploy the supabase edge functions if modified.
If you done with it, you can close this issue.
@fszontagh I'm starting work on this now!
I see you've asked me to:
Let me check the deployment status first and then update the documentation.
@fszontagh ✅ All tasks completed!
What I've done:
1. Verified Edge Function Deployment Status
Yes, the
oauth-woocommerceEdge Function was successfully deployed earlier:585b6f7)2. Updated CLAUDE.md Documentation
I've added a comprehensive new section titled "⚠️ Critical: Deploying Edge Function Changes" to the Development Workflow section.
The new documentation includes:
Changes committed:
23e7ed4- "docs: add critical reminder about redeploying Edge Functions after modifications #17"3. Closing the Issue
This issue is now resolved. The documentation has been updated to ensure future Edge Function modifications won't be forgotten to deploy.
Location in CLAUDE.md: Lines 548-578 (Development Workflow → Critical: Deploying Edge Function Changes)
Closing this issue now! 🎉
✅ Issue #17 is now closed!
All requested tasks have been completed:
The documentation now includes a dedicated section that will help prevent this issue in the future by reminding developers to always redeploy Edge Functions after modifications.