NextAuth Custom Provider with Prisma Adapter not working well
Unanswered
Polar bear posted this in #help-forum
Polar bearOP
I am getting this error on account signin for the first time:
Provider:
Auth Options:
Argument `user` is missing. Error:
Invalid `prisma.account.create()` invocation:Provider:
export default function Whop<P extends WhopProfile>(
options: OAuthUserConfig<P>
): OAuthConfig<P> {
return {
id: "whop",
name: "Whop",
type: "oauth",
authorization: {
url: "https://whop.com/oauth",
// params: {
// scope: "openid",
// },
},
token: "https://data.whop.com/api/v3/oauth/token",
userinfo: "https://api.whop.com/api/v2/me",
profile(profile) {
return {
id: profile.id,
name: profile.username,
email: profile.email,
image: profile.profile_pic_url,
};
},
style: {
logo: "https://whop.com/v2/whop-logo-circle.png",
logoDark: "https://whop.com/v2/whop-logo-circle.png",
bg: "#fff",
text: "#FF6243",
bgDark: "#FF6243",
textDark: "#fff",
},
options,
};
}Auth Options:
export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => {
console.log(session, user);
console.log("session");
return {
...session,
user: {
...session.user,
id: user.id,
},
};
},
signIn: ({ user, account, profile, email, credentials }) => {
console.log(user, account, profile, email, credentials);
console.log("signIn");
return true;
},
redirect: ({ url, baseUrl }) => {
console.log("hi");
console.log(url);
return url.startsWith(baseUrl) ? url : baseUrl;
},
jwt: ({ token, user, account, profile, isNewUser }) => {
console.log(token, user, account, profile, isNewUser);
console.log("jwt");
return token;
},
},
adapter: PrismaAdapter(prisma),
providers: [
Whop({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
clientId: "",
clientSecret: "",
}),
/**
* ...add more providers here.
*
* Most other providers require a bit more work than the Discord provider. For example, the
* GitHub provider requires you to add the `refresh_token_expires_in` field to the Account
* model. Refer to the NextAuth.js docs for the provider you want to use. Example:
*
* @see https://next-auth.js.org/providers/github
*/
],
};