Two providers one user

Is there a way of having two providers (discord and steam) in next auth link up to the same user?
Solution:
got it just had to add allowDangerousEmailAccountLinking: true, to the provider options
Jump to solution
14 Replies
SafeShows
SafeShows•15mo ago
I'm using next-auth/providers/discord for discord and next-auth-steam for steam provider and here's my [...nextauth].ts
import NextAuth from "next-auth";
import { authOptions } from "@/server/auth";
import DiscordProvider from "next-auth/providers/discord";
import SteamProvider from "next-auth-steam";
import type { NextApiRequest, NextApiResponse } from "next";
import { env } from "@/env.mjs";

export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
authOptions.providers = [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
SteamProvider(req, {
clientSecret: env.STEAM_SECRET!,
callbackUrl: "http://localhost:3000/api/auth/callback/steam",
}),
];
return NextAuth(req, res, authOptions);
}
import NextAuth from "next-auth";
import { authOptions } from "@/server/auth";
import DiscordProvider from "next-auth/providers/discord";
import SteamProvider from "next-auth-steam";
import type { NextApiRequest, NextApiResponse } from "next";
import { env } from "@/env.mjs";

export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
authOptions.providers = [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
SteamProvider(req, {
clientSecret: env.STEAM_SECRET!,
callbackUrl: "http://localhost:3000/api/auth/callback/steam",
}),
];
return NextAuth(req, res, authOptions);
}
kB_
kB_•15mo ago
I mean you could but generally providers are handled separately
Solution
SafeShows
SafeShows•15mo ago
got it just had to add allowDangerousEmailAccountLinking: true, to the provider options
kB_
kB_•15mo ago
Thumbglass nice
SafeShows
SafeShows•15mo ago
ik not the best but it works I guess
kB_
kB_•15mo ago
yep whatever works
Leigham
Leigham•15mo ago
what steam provider did you use ?
SafeShows
SafeShows•15mo ago
https://www.npmjs.com/package/next-auth-steam but I change some of the code on my end
npm
next-auth-steam
Steam authentication provider for next-auth. Latest version: 0.1.0, last published: a day ago. Start using next-auth-steam in your project by running npm i next-auth-steam. There are no other projects in the npm registry using next-auth-steam.
SafeShows
SafeShows•15mo ago
npm
@milahu/patch-package
Fix broken node modules with no fuss. Latest version: 6.4.14, last published: a year ago. Start using @milahu/patch-package in your project by running npm i @milahu/patch-package. There are 5 other projects in the npm registry using @milahu/patch-package.
SafeShows
SafeShows•15mo ago
@Cox Insider I hope that help you ^^^
Leigham
Leigham•15mo ago
yeah, its similar to the one I made already, but still not compatible with auth.js 😦
SafeShows
SafeShows•15mo ago
can I see ur one?
Leigham
Leigham•15mo ago
its like the one in the package, just uses fetch instead of the openid library
SafeShows
SafeShows•15mo ago
ohh yeah that works too