-
My import NextAuth from "next-auth";
import DiscordProvider from "next-auth/providers/discord";
export default NextAuth({
// Configure one or more authentication providers
providers: [
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET,
authorization:
"https://discord.com/api/oauth2/authorize?scope=identify+email+guilds",
profile(profile) {
console.log(profile)
return {
accent_color: profile.accent_color,
avatar: profile.avatar,
banner: profile.banner,
banner_color: profile.banner_color,
discriminator: profile.discriminator,
email: profile.email,
flags: profile.flags,
id: profile.id,
image_url: profile.image_url,
locale: profile.locale,
mfa_enabled: profile.mfa_enabled,
premium_type: profile.premium_type,
public_flags: profile.public_flags,
username: profile.username,
verified: profile.verified,
};
},
// test with callback
callbacks: {
async session({ session, token, user }) {
// Send properties to the client, like an access_token from a provider.
session.accessToken = token.accessToken;
console.log(user);
console.log("here");
return session;
},
},
}),
],
pages: {
signIn: "/login",
},
}); The default data I receive without the {
"name": "my_discord_name",
"email": "[email protected]",
"image": "https://myDiscordAvatar.com/avatar.png"
} Does anyone know how to do that? Pretty sure I've overlooked it somewhere but couldn't find anything that worked for me so far. |
Beta Was this translation helpful? Give feedback.
Answered by
ArkShocer
Oct 3, 2022
Replies: 1 comment
-
Got it by changing the following 🙂 callbacks: {
async jwt({ token, account, profile }) {
// Persist the OAuth access_token to the token right after signin
// console.log(profile.verified)
if (account) {
token.accessToken = account.access_token;
token.id = profile.id;
token.email = profile.email;
token.profile = profile;
}
return token;
},
async session({ session, token }) {
// Send properties to the client, like an access_token from a provider.
// session.accessToken = token.accessToken; // Dont forget to remove the token later boi!
session.user = {
email: token.email,
id: token.id,
profile: token.profile,
};
return session;
},
}, |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ArkShocer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got it by changing the following 🙂