Exploring methods to modify the Discord scopes in the upcoming Auth v5 update

image description placeholder I'm trying to modify the scope, remove the email and include guilds in my project. I searched for a solution but couldn't find one that worked. Can anyone help me figure out how to change the scopes?

I attempted to make changes using the following code.

import NextAuth from "next-auth"
import Discord from "next-auth/providers/discord"
import type { NextAuthConfig } from "next-auth"

export const config = {
  theme: {
    logo: "https://next-auth.js.org/img/logo/logo-sm.png",
  },
  providers: [
    Discord({ clientId: "1183095707033403462", clientSecret: "HQAtuIRXhgl3sH3oW9cNYXgX8VmOO82N", authorization: { params: { scope: 'identify guilds' } }
   })
  ],
  callbacks: {
    authorized({ request, auth }) {
      const { pathname } = request.nextUrl
      if (pathname === "/middleware-example") return !!auth
      return true
    },
  },
} satisfies NextAuthConfig

export const { handlers, auth, signIn, signOut } = NextAuth(config)

This approach doesn't seem to be effective :(

Answer №1

My experience with Next Auth led me to discover that it is lacking in documentation. It took a lot of trial and error, but I eventually managed to unravel the mystery. The key takeaway was that the authorization value should not be an object, but rather included in the Discord OAuth URL:

Discord({
  clientId: '...',
  clientSecret: '...',
  authorization: 'https://discord.com/oauth2/authorize?scope=identify+guilds'
})

It's important to remember not to expose your environment variables (client ID and secret) on platforms like Stack Overflow for security reasons.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

connect a column from a separate array in pdfmake

In my current project, I am looking to link the values of an array that is different from the one present in the initial two columns. Is this achievable? (The number of partialPrice values aligns with the number of code entries). Despite several attempts ...

Including the file path to an image in a CSS module within a React component from the public directory

I'm currently facing a challenge with adding an image as a background, especially since the image is located in a public folder structure like this: -public -images -image.png -src -assets -components -index.tsx -index.module.css (I want to use the ...

The userId argument received the invalid value of '5106220' when calling Prisma.findManyTodos. The function was expecting either an IntFilter or an Int value instead of a String

After setting up my project with next.js, next-auth, Prisma, and PostgreSQL, I encountered an issue when trying to log in with social providers. My userId in the database is stored as an Integer, which works fine when logging in with credentials. However, ...

Ways to display a red alert message below an input field in React and Next.js when the input value is incorrect

<input aria-required className="bg-white text-black h-40px text-lg hover:border-blue-400 border-solid border-b-2 w-[87%] " id="" placeholder="" ...

Steps to Verify if Cookie is Turned Off in a Next.js Application

I have encountered an issue with my Next.js App. It seems to be functioning properly until I disable cookies in the browser. Is there a way for me to determine if cookies are disabled in the browser and display a corresponding message? I attempted to check ...

The TypeScript compiler is unable to locate the name 'window'

Within my Meteor/React project, I encounter the following line of code: let gameId = window.prompt("Please input the ID of the game you would like to load."); The TypeScript compiler presents an error during transpiling: Cannot find name 'window&apo ...

What steps can be taken to fix the error message "Type circularly references itself"?

Here's an example of an issue with a predictable outcome: const actionTypes = { name: { set: "name/set", }, } as const; type ActionTypes = { [key: string]: (string | ActionTypes) }; //record value is string or ActionTypes // " ...

The custom pagination feature in MUI DataGridPro does not display the rowsPerPageOptions dropdown as expected

I am currently utilizing React in my project. "react": "^18.2.0", "@mui/material": "^5.10.7", "@mui/x-data-grid-pro": "^5.16.0" An issue arises with the visibility of the rowsPerPageOptions dr ...

Generating an Object Using HttpClient

When working with httpclient, you can specify the type for the get call and receive a struct of that object. For example. http.get<ProductData>("url:ressource:id").subscribe(x=> this.myObj = x) This means that myObj will only appear to ...

What is the correct way to declare and use the useState hook in React?

I am currently working with TypeScript interfaces and the useState hook, attempting to properly type them. However, I encountered an error when comparing a prop variable with a useState variable. The error message states that This comparison appears to be ...

Changing the color of an Angular <div> element with scripting

I am currently working on an Angular 6 project and I need to change the colors of a div tag from a script after a click function. However, I also need to change it back to transparent. When I click on the "Inheritance" option, the background color of the ...

What is the best way to ensure that two promises are both resolved before triggering a function from within a promise?

In my code, I have a forEach loop on a matches fetch that looks like this: matches => { matches.forEach(match => { Promise.all([this.teamService.getTeam(match._links.homeTeam.href)]) .then(team => { match. ...

Using Jest and TypeScript to mock the return value of react-oidc-context

For our project, we utilize react-oidc-context to handle user authentication using oidc-client-ts under the hood. The useAuth function provided by react-oidc-context gives us access to important information such as isAuthenticated, isLoading, and the auth ...

Retrieve a list of class names associated with a Playwright element

Can anyone suggest the best method to retrieve an array of all class names for an element in Playwright using TypeScript? I've searched for an API but couldn't find one, so I ended up creating the following solution: export const getClassNames = ...

When running the command "npx create-next-app@latest --ts," be aware that there are 3 high severity vulnerabilities present. One of the vulnerabilities is that "node-fetch

Just set up a fresh project with Next.js and TypeScript by following the documentation using npx create-next-app@latest --ts. Encountering multiple high severity vulnerabilities despite running npm audit fix --force, which actually adds more vulnerabiliti ...

What is the best way to send serverside parameters from ASP.Core to React?

After setting up a React/Typescript project using dotnet new "ASP.NET Core with React.js", I encountered the following setup in my index.cshtml: <div id="react-app"></div> @section scripts { <script src="~/dist/main.js" asp-append-versi ...

Can getters and setters be excluded from code coverage reports in Angular projects?

Looking to clean up my coverage reports for the front end portion of an angular project by removing trivial code like getters and setters. I generate my reports using npm run test-sonar -- --coverage, but everything is included in the report when I view ...

Optimizing Firebase and Next.js for serverless deployment on Google Cloud Platform: A guide to effectively managing staging, production, and

Currently, I am utilizing React along with next.js and Google Cloud functions to host my application. Additionally, I am integrating firebase into the mix. One pressing issue I am facing pertains to efficiently configuring the staging and production enviro ...

I am facing an issue retrieving my Strapi data within my Next.js application

I am currently working on developing my portfolio website using Next.js and Strapi, but I am facing challenges when it comes to displaying the data from the about page on the screen. Even though I am able to fetch the data using Postman, I seem to encounte ...

Tips for extracting and entering a value in a React form from a dropdown menu and an input field

Currently working on developing an application for organizing cocktail recipes. Facing an issue with data types for a particular line within a form that includes both select and input elements. Looking for guidance on how to correctly read the data from t ...