jess
jess2y ago

Next.js: Clerk NoAuthProvider Error

Upon cloning https://github.com/get-convex/convex-nextjs-app-router-demo I get the error
Failed to authenticate: "NoAuthProvider: No auth provider found matching the given token", check your server auth config
Failed to authenticate: "NoAuthProvider: No auth provider found matching the given token", check your server auth config
when attempting sign-in with my Clerk credentials in .env.local and in my convex env settings on localhost:3000 after running npm run dev my .env.local is as follows:
# Deployment used by `npx convex dev`
CONVEX_DEPLOYMENT=dev:[redacted]

NEXT_PUBLIC_CONVEX_URL="https://[redacted].convex.cloud"

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=[redacted]
CLERK_SECRET_KEY=[redacted]
CLERK_JWT_ISSUER_DOMAIN=https://[redacted].clerk.accounts.dev
# Deployment used by `npx convex dev`
CONVEX_DEPLOYMENT=dev:[redacted]

NEXT_PUBLIC_CONVEX_URL="https://[redacted].convex.cloud"

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=[redacted]
CLERK_SECRET_KEY=[redacted]
CLERK_JWT_ISSUER_DOMAIN=https://[redacted].clerk.accounts.dev
GitHub
GitHub - get-convex/convex-nextjs-app-router-demo: Demo showing a N...
Demo showing a Next.js App Router app powered by Convex backend - GitHub - get-convex/convex-nextjs-app-router-demo: Demo showing a Next.js App Router app powered by Convex backend
12 Replies
ballingt
ballingt2y ago
What does your convex/auth.config.js look like?
jess
jessOP2y ago
it's unchanged from the starter code
const config = {
providers: [
{
domain: process.env.CLERK_JWT_ISSUER_DOMAIN,
applicationID: "convex",
},
],
};

export default config;
const config = {
providers: [
{
domain: process.env.CLERK_JWT_ISSUER_DOMAIN,
applicationID: "convex",
},
],
};

export default config;
and my clerk JWT is called "convex" just confirmed the claims in clerk!
{
"aud": "convex",
"name": "{{user.full_name}}",
"email": "{{user.primary_email_address}}",
"picture": "{{user.image_url}}",
"nickname": "{{user.username}}",
"given_name": "{{user.first_name}}",
"updated_at": "{{user.updated_at}}",
"family_name": "{{user.last_name}}",
"email_verified": "{{user.email_verified}}"
}
{
"aud": "convex",
"name": "{{user.full_name}}",
"email": "{{user.primary_email_address}}",
"picture": "{{user.image_url}}",
"nickname": "{{user.username}}",
"given_name": "{{user.first_name}}",
"updated_at": "{{user.updated_at}}",
"family_name": "{{user.last_name}}",
"email_verified": "{{user.email_verified}}"
}
ballingt
ballingt2y ago
I can't think of anything, all looks reasonable! I'll clone and see if I can repro.
jess
jessOP2y ago
thanks so much (and wow such speedy replies ❤️ ). to clarify the name of my application in Clerk is not convex, but I'm assuming that's irrelevant
ballingt
ballingt2y ago
I'm not hitting this, my .env.local looks like
# Deployment used by `npx convex dev`
CONVEX_DEPLOYMENT=dev:happy-otter-123 # team: thomasballinger, project: convex-nextjs-app-router-demo

NEXT_PUBLIC_CONVEX_URL="https://happy-otter-123.convex.cloud"
CLERK_JWT_ISSUER_DOMAIN="https://pleasant-mouse-1.clerk.accounts.dev"
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_ZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
# Deployment used by `npx convex dev`
CONVEX_DEPLOYMENT=dev:happy-otter-123 # team: thomasballinger, project: convex-nextjs-app-router-demo

NEXT_PUBLIC_CONVEX_URL="https://happy-otter-123.convex.cloud"
CLERK_JWT_ISSUER_DOMAIN="https://pleasant-mouse-1.clerk.accounts.dev"
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_ZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
jess
jessOP2y ago
thanks for the attempt to repro!
ballingt
ballingt2y ago
I did hit a schema issue a moment later though! I wasn't getting a username and had to make it optional in the schema
jess
jessOP2y ago
might be unquoted jwt in my env 😮‍💨 we'll see
ballingt
ballingt2y ago
In my Convex dashboard my environment variables look like this
No description
ballingt
ballingt2y ago
sounds like the Clerk settings match, just in case here's mine
No description
jess
jessOP2y ago
ohh i feel silly - i had corrected my var from JWKS Endpoint -> Issuer when rereading the instructions in .env.local but not in the convex vars it works now 🥳 🥳
ballingt
ballingt2y ago
🎉

Did you find this page helpful?