How to get the discord guilds from the user next-auth

I already tried it with scope but I dont know how to fetch the scope data. I dont find any documentations about scopes on next-auth https://pastebin.com/MJGJf8K3
Pastebin
import { PrismaAdapter } from "@next-auth/prisma-adapter";import { ...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
No description
Solution:
nvm, have to delete the account record of the user. I changed the scope before I logged in first time, so the token was invalid...
Jump to solution
4 Replies
papsn
papsn12mo ago
getting 401
await fetch("https://discordapp.com/api/v9/users/@me", {
headers: {
Authorization: "Bearer " + account?.access_token,
},
})
.then(async (guilds) => {
console.log(guilds);
console.log(guilds.status);

return guilds;
})
.catch(console.error);
await fetch("https://discordapp.com/api/v9/users/@me", {
headers: {
Authorization: "Bearer " + account?.access_token,
},
})
.then(async (guilds) => {
console.log(guilds);
console.log(guilds.status);

return guilds;
})
.catch(console.error);
Solution
papsn
papsn12mo ago
nvm, have to delete the account record of the user. I changed the scope before I logged in first time, so the token was invalid
Rhys
Rhys12mo ago
The @Answer Overflow bot is open source and does a lot with Next Auth and the Discord api, https://github.com/AnswerOverflow/AnswerOverflow/blob/main/packages/cache/src/discord.ts may be helpful
GitHub
AnswerOverflow/packages/cache/src/discord.ts at main · AnswerOverfl...
Indexing Discord Help Channel Questions into Google - AnswerOverflow/AnswerOverflow
Rhys
Rhys12mo ago
You’re going to need to make tokens refresh otherwise your API calls will break, we do that here: https://github.com/AnswerOverflow/AnswerOverflow/blob/main/packages/auth/src/auth-options.ts
Want results from more Discord servers?
Add your server