I was following this example: https://github.com/nextauthjs/sveltekit-auth-example, and it worked great.
Then, I added the Slack provider to hooks.server.ts
:
export const handle = SvelteKitAuth({
providers: [
//@ts-expect-error issue https://github.com/nextauthjs/next-auth/issues/6174
GitHub({ clientId: GITHUB_ID, clientSecret: GITHUB_SECRET }),
//@ts-expect-error issue https://github.com/nextauthjs/next-auth/issues/6174
Slack({clientId: SLACK_CLIENT_ID, clientSecret: SLACK_CLIENT_SECRET}),
]
})
and updated vite.config.ts
to use https:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
import basicSsl from '@vitejs/plugin-basic-ssl';
export default defineConfig({
plugins: [sveltekit(), basicSsl()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
server: {https: true}
});
Now I get the following error when trying to login with slack:
[auth][error][CallbackRouteError]: Read more at https://errors.authjs.dev#callbackrouteerror
[auth][cause]: OperationProcessingError: unexpected ID Token "nonce" claim value
at Module.processAuthorizationCodeOpenIDResponse (file:///home/ubuntu/dev/auth.js/node_modules/oauth4webapi/build/index.js:1037:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async handleOAuth (file:///home/ubuntu/dev/auth.js/node_modules/@auth/sveltekit/node_modules/@auth/core/lib/oauth/callback.js:79:24)
at async Module.callback (file:///home/ubuntu/dev/auth.js/node_modules/@auth/sveltekit/node_modules/@auth/core/lib/routes/callback.js:14:41)
at async AuthInternal (file:///home/ubuntu/dev/auth.js/node_modules/@auth/sveltekit/node_modules/@auth/core/lib/index.js:64:38)
at async Proxy.Auth (file:///home/ubuntu/dev/auth.js/node_modules/@auth/sveltekit/node_modules/@auth/core/index.js:100:30)
at async Module.respond (/node_modules/@sveltejs/kit/src/runtime/server/respond.js:259:20)
at async file:///home/ubuntu/dev/auth.js/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:506:22
[auth][details]: {
"provider": "slack"
}