Next.js Discord

Discord Forum

More than one credential Provier next-auth

Answered
Naeemgg posted this in #help-forum
Open in Discord
Avatar
If we are using more than one cred provider how can we mention its id in SignIn() function??
providers: [
  CredentialsProvider({
    id: "domain-login",
    name: "Domain Account",
    async authorize(credentials, req) {
      const user = {
        /* add function to get user */
      }
      return user
    },
    credentials: {
      domain: {
        label: "Domain",
        type: "text ",
        placeholder: "CORPNET",
        value: "CORPNET",
      },
      username: { label: "Username", type: "text ", placeholder: "jsmith" },
      password: { label: "Password", type: "password" },
    },
  }),
  CredentialsProvider({
    id: "intranet-credentials",
    name: "Two Factor Auth",
    async authorize(credentials, req) {
      const user = {
        /* add function to get user */
      }
      return user
    },
    credentials: {
      username: { label: "Username", type: "text ", placeholder: "jsmith" },
      "2fa-key": { label: "2FA Key" },
    },
  }),
  /* ... additional providers ... /*/
]

source: https://next-auth.js.org/providers/credentials#:~:text=You%20can%20specify%20more%20than%20one%20credentials%20provider,in%20page.%20%2F%2A%20...%20additional%20providers%20...%20%2F%2A%2F
Answered by Naeemgg
we just need to pass the id instead of credentials SignIn("id")
View full answer

2 Replies

Avatar
Avatar
we just need to pass the id instead of credentials SignIn("id")
Answer