Stripe creating subscription: Unauthorized 401
Hello, I'm running into an issue with Stripe Subscriptions whereas I cannot generate a new subscription for an user. I'm using @better-auth/strip and receive a 401 Unauthorized when I'm creating a subscription on the client. The only weird thing AFAIK is that I use the convexAdapter, so I cannot run migrations for stripe myself (but this seems unrelated to the unauthorized).
I've checked the .env.local keys a dozen times. I'm running a Tanstack Start app.
auth.tsx
Solution:Jump to solution
```typescript
subscription: defineTable({
id: v.string(), // <-- this was the problem
plan: v.string(),
referenceId: v.id("user"),...
28 Replies
auth-client.ts
Client code:
Hey, are you sure you're logged before creating a subscription?
Hey @Ping, yes I'm logged into my user with better-auth
Does the error give you any other details besides that it's "Unauthorized 401"?
This is the entire error
I dont think it has to do with the convex adapter
Yeah, it's very unlikely. :)
By the way, I'm the creator of the Convex adapter, if you run into any issues don't hesitate to just ping me :)
haha nice 🙂 I know 🙂
Can you test without passing
referenceId
in your subscription.upgrade call?ah the error changed to a 500
Maybe there's an error in your logs now? 👀
Well! That sure seems more like a Convex adapter issue xD
yep XD
I would've been perfect if it was plug and play 😛
Can you enable debug logs from the convex adapter options?
the subscription table is not getting new entries
Hmm.
This.. is very strange.
yes, the create is in the logging but the table remains empty
The data which the create log shows seem to be some very basic data too, nohing complex or anything...
Makes no sense why it would break...
No rush, I can log it on github if you want
Yeah please create an issue on my repo
I think I'll have to reproduce a demo and test myself. I'll test this when I wake, it's 6am rn 😅
GitHub
Convex Adapter and Stripe plugin not working: Error {} is not a sup...
I'm receiving the following error when creating a Stripe subscription: # SERVER_ERROR: Error: [Request ID: 91870f8125d70b9e] Server Error Uncaught Error: Error {} is not a supported Convex type...
Thanks for the help!
Im just seeing this error logging right now in the
Do you have a schema defined for subscription?
yes
hold on, I'm just checking it
yup it works.

without the schema
Solution
Sorry for the trouble. But now you know it works!
convex adapter and stripe plugin work well, if you're not misconfiguring it ;O
No not your fault at all!
This is actually my fault 👀
adapters are meant to provide an
id
during row creation if the data didn't already provide one..
When creating the convex adapter, it was a while ago while I was still somewhat new to BA as well... so there are definitely pitholes which I'm sure I didn't take into account.
The good news is that all of those pitholes will be fixed from my PR in better-auth to introduce a createAdapter
helper.
Anyway, details aside, I'm glad it's solved!Ah okay. Pretty amazing experience with integrating it for such a new library.