Next.js Discord

Discord Forum

Authjs Custom OAUTH/OIDC provider

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
Hello I hope it is okay to aks questions about authjs.
I need to implement login with some provider that is not built in, so i made custom config for provider.
This is my configuration

{
      id: 'aaiedu',
      name: 'AAIEDU',
      type: 'oidc',
      issuer: 'https://fed-lab.aaiedu.hr',
      clientId: process.env.AAIEDU_CLIENT_ID,
      clientSecret: process.env.AAIEDU_CLIENT_SECRET,
      userinfo: 'https://fed-lab.aaiedu.hr/sso/module.php/oidc/userinfo.php',
      token: 'https://fed-lab.aaiedu.hr/sso/module.php/oidc/token.php',
      authorization: {
        params: {
          redirect_uri: process.env.AAIEDU_REDIRECT_URL,
          scope:
            'openid profile email phone hrEduPersonOIB sn displayName offline_access cn hrEduPersonUniqueID mail hrEduPersonRole',
          prompt: 'login'
        }
      }
    }


When i start app locally it works fine, problem is when i deploy my app i get error.
Login form opens and i type in email/password, but then it redirects me to http://0.0.0.0:3000/api/auth/error?error=Configuration and i get log


challenge { scheme: 'basic', parameters: { realm: 'OAuth' } }
[auth][error] CallbackRouteError: Read more at https://errors.authjs.dev#callbackrouteerror
[auth][cause]: Error: TODO: Handle www-authenticate challenges as needed
    at ix (/app/.next/server/chunks/4458.js:393:28065)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async i$ (/app/.next/server/chunks/4458.js:393:34162)
    at async iJ (/app/.next/server/chunks/4458.js:393:45566)
    at async iB (/app/.next/server/chunks/4458.js:393:50436)
    at async /app/node_modules/.pnpm/next@14.0.4_@babel+core@7.24.4_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:41960
[auth][details]: {
  "provider": "aaiedu"
}

App is deployed on amplify.
I did also set NEXT_AUTH_URL and set trustHost: true
Do I need set some additional things?

0 Replies