I'm getting - Try signing in with a different account. #4415
-
Question 💬I am trying to sign with Github provider, but I am getting a message `Try signing in with a different account. How to reproduce ☕️
.env file:
and [...nextauth].ts file: import NextAuth from 'next-auth';
import { PrismaAdapter } from '@next-auth/prisma-adapter';
import { PrismaClient } from '@prisma/client';
import GitHubProvider from 'next-auth/providers/github';
const prisma = new PrismaClient();
export default NextAuth({
adapter: PrismaAdapter(prisma),
providers: [
GitHubProvider({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
}),
],
secret: process.env.SECRET,
pages: {
//signIn: '/auth/signin', // Displays signin buttons
// signOut: '/auth/signout', // Displays form with sign out button
// error: '/auth/error', // Error code passed in query string as ?error=
// verifyRequest: '/auth/verify-request', // Used for check email page
},
// Callbacks are asynchronous functions you can use to control what happens
// when an action is performed.
// https://next-auth.js.org/configuration/callbacks
callbacks: {
// async signIn(user, account, profile) { return true },
// async redirect(url, baseUrl) { return baseUrl },
// async session(session, user) { return session },
// async jwt(token, user, account, profile, isNewUser) { return token }
},
// Events are useful for logging
// https://next-auth.js.org/configuration/events
events: {
signIn: ({ user, account, profile, isNewUser }) => {
console.log(`isNewUser: ${JSON.stringify(isNewUser)}`);
},
// updateUser({ user })
},
// Enable debug messages in the console if you are having problems
debug: true,
}); when i try to sign in console error: provider: {
id: 'github',
name: 'GitHub',
type: 'oauth',
authorization: {
url: 'https://github.com/login/oauth/authorize',
params: [Object]
},
token: { url: 'https://github.com/login/oauth/access_token', params: {} },
userinfo: {
url: 'https://api.github.com/user',
request: [AsyncFunction: request]
},
profile: [Function: profile],
idToken: false,
checks: [ 'state' ],
clientId: '',
clientSecret: '',
signinUrl: 'http://localhost:3000/api/auth/signin/github',
callbackUrl: 'http://localhost:3000/api/auth/callback/github'
},
message: 'client_id is required'
} Contributing 🙌🏽No, I am afraid I cannot help regarding this |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 7 replies
-
Do you mean GitHub provider? |
Beta Was this translation helpful? Give feedback.
-
@ThangHuuVu error solved. Thanks for helping. |
Beta Was this translation helpful? Give feedback.
-
i'm having a same erorr but in google provider |
Beta Was this translation helpful? Give feedback.
-
Hi, I am getting the same error with Okta provider. I have the following keys set in my
|
Beta Was this translation helpful? Give feedback.
-
i got the same error. After trying for more than an hour i found out that there was an extra / in the callback URL i provided to GitHub for OAuth |
Beta Was this translation helpful? Give feedback.
-
i got the same error but with apple login......can anyone help? |
Beta Was this translation helpful? Give feedback.
-
I had the same issue, but my .env file was in the wrong location. |
Beta Was this translation helpful? Give feedback.
-
import NextAuth from "next-auth"; const handler= NextAuth({ export {handler as GET, handler as POST} just add httpOptions: { |
Beta Was this translation helpful? Give feedback.
-
Solution for Google login for docker: Run commands in this sequence:
It will mostly solve your issue. If you have |
Beta Was this translation helpful? Give feedback.
Do you mean GitHub provider?
You'll need to provide the
GITHUB_ID
andGITHUB_SECRET
for the provider to work correctly. See how to obtain the value here: https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps