Using passport-steam and supabase auth in nextjs.

My idea is to let people sign in with discord using supabase. After a successful log in they have a option to "link" their discord account with steam. After the linking process their steam-id should be inserted into the supabase profiles table. Supabase does not have steam as a official authentication provider so i'm using passport-steam for the steam part. The passport-steam strategy looks like this: const SteamStrategy = passportSteam.Strategy;
export interface SteamProfile {
displayName: string;
id: string;
identifier: string;
photos: Image;
provider: string;
}

interface Image {
value: string;
}
passport.serializeUser(function (user, done) {
done(null, user);
});

passport.deserializeUser(function (obj: SteamProfile, done) {
done(null, obj);
});

passport.use(
new SteamStrategy(
{
returnURL: `${process.env.DOMAIN}/api/auth/return`,
realm: `${process.env.DOMAIN}`,
apiKey: `${process.env.STEAM_API_KEY}`,
},
(
_: string,
profile: SteamProfile,
done: (a: null | string, b: SteamProfile) => typeof done
) => {

return done(null, profile);

}
)
);

export default passport;
export interface SteamProfile {
displayName: string;
id: string;
identifier: string;
photos: Image;
provider: string;
}

interface Image {
value: string;
}
passport.serializeUser(function (user, done) {
done(null, user);
});

passport.deserializeUser(function (obj: SteamProfile, done) {
done(null, obj);
});

passport.use(
new SteamStrategy(
{
returnURL: `${process.env.DOMAIN}/api/auth/return`,
realm: `${process.env.DOMAIN}`,
apiKey: `${process.env.STEAM_API_KEY}`,
},
(
_: string,
profile: SteamProfile,
done: (a: null | string, b: SteamProfile) => typeof done
) => {

return done(null, profile);

}
)
);

export default passport;
My guess would be that i should use this in the passport.use:
const { error } = await supabase
.from('profiles')
.update({ steamid: profile.id })
.eq('id', discord_id)
const { error } = await supabase
.from('profiles')
.update({ steamid: profile.id })
.eq('id', discord_id)
But i have no idea how could i get the logged in users discord id.
3 Replies
Torbjörn
Torbjörn2y ago
Hey, @H1GHG2M3R did you ever figure this out? I was running into the same thing and it is one of the only things that is stopping me from leveraging supabase.
botants
botantsOP2y ago
Im working on a different project right now but this is an answer i got on stackoverflow: "This looks like you are trying to mix the auth-helpers with an express auth library. You should just use the normal supabase-js in this circumstance as the auth-helpers are expecting NextJS request and response objects."
Torbjörn
Torbjörn2y ago
Thank you!
Want results from more Discord servers?
Add your server