I’m currently implementing the RevenueCat Web SDK in a React application, and I’m encountering an issue during the configuration step. When I initialize Purchases.configure(), I receive the following error:
Error configuring RevenueCat: _me: Invalid API key. Use your Web Billing API key.
I have confirmed that I am using what should be the correct Web Billing API Key, but the SDK continues to throw this error. I’m unable to pinpoint what might be causing it.
Below is the relevant code snippet from my implementation:
import { Purchases } from '@revenuecat/purchases-js'; useEffect(() => { if (hasConfiguredPurchases.current) return; if (!userInfo && !userDetails) return; try { let appUserId = userInfo?.user_uuid || userDetails?.user_id; if (!appUserId) { appUserId = typeof Purchases.generateRevenueCatAnonymousAppUserId === 'function' ? Purchases.generateRevenueCatAnonymousAppUserId() : `anon_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`; } const purchases = Purchases.configure({ apiKey: REVENUECAT_API_KEY, appUserId, }); setPurchasesInstance(purchases); hasConfiguredPurchases.current = true; console.log('RevenueCat configured successfully', { appUserId }); } catch (error) { console.error('Error configuring RevenueCat:', error); } },[userInfo, userDetails]); const REVENUECAT_API_KEY = 'rcb_ip...*****...yp';
"@revenuecat/purchases-js": "^0.18.2", "react": "^18.3.1",
If possible, could you help me identify why the SDK is rejecting the API key even though it appears to be valid?
