Zero Sync Authentication
https://zero.rocicorp.dev/docs/auth - zero
https://www.better-auth.com/docs/plugins/jwt - jwt
How to intergrate jwt with zero
Zero Docs
The official documentation for Zero by Rocicorp.
JWT | Better Auth
Authenticate users with JWT tokens in services that can't use the session
Solution:Jump to solution
If anyone is wandering how to get better auth with nextjs.
Link : https://discord.com/channels/830183651022471199/1361694110972645597/1361898149475778732...
14 Replies
set
ZERO_AUTH_JWKS_URL
https://your-site.com/api/auth/jwks
and in the token you can fetch for the jwt token from "/token" endpointThat gives me the error "kind":"AuthInvalidated" │,"message":"Failed to decode auth token: JWTClaimValidationFailed: unexpected "sub" claim value"
Any luck? I am twisting my hair here thinking of with rolling my own session based/jwt
No nothing yet I'm also suck of this err
can you guys try this version
pnpm i https://pkg.pr.new/better-auth/better-auth@2194
and report backOk it worked with me, zero can can decode my jwt token through ZERO_AUTH_JWKS_URL='http://localhost:3000/api/auth/jwks' what i did was I removed the ZERO_AUTH_SECERT= and also i ended the cache server dev:cache rebuilt it with npm rebuild and it worked. i have no clue what made it work but yeah whenever i was runing into issues i just closed my cache dev and rebuilt and reran it
it worked with the version I sent above?
no but i am on the latest version of better-auth I think the there is a conflict between the better auth secert and zero auth secert because whenever i add it i get the same error message
Event If I've used ZERO_AUTH_JWKS_URL and zero decode the auth it gives a claim error,
have you treid the patch version?
Yes Still worker=syncer pid=12680 errorKind=AuthInvalidated Sending error on WebSocket {"kind":"AuthInvalidated","message":"Failed to decode auth token: JWTClaimValidationFailed: unexpected "sub" claim value"} comming from zero cache
How are you getting the jwt from authClient.token without passing the header options such as cookie ? are you sure you are getting a jwt token?
authClient gets the cookies and headers automaticly so I don't need to spacify manually. also I've tried to get the token manually with authclient.token and It gave me a correct token
Solution
If anyone is wandering how to get better auth with nextjs.
Link : https://discord.com/channels/830183651022471199/1361694110972645597/1361898149475778732