Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
How do I solve Redirect URI is not supported by the client in Discord OAuth2

Hey there StackOverflow community ๐Ÿ‘‹. I'm implementing a web app which brings out all the possible information of a Discord user. Currently in the backend of my project I use express | passport | passport-discord (I am also following a tutorial on YouTube). The relevant code is

strategies/discord.js

const DiscordStrategy = require('passport-discord').Strategy;
const passport = require('passport');
const config = require('config');
var scopes = ['identify', 'email', 'guilds'];

passport.use(new DiscordStrategy({
    clientID: config.get('discord.clientID'),
    clientSecret: config.get('discord.clientSecret'),
    callbackURL: config.get('discord.redirectURL'),
    scope: scopes
}, (accessToken, refreshToken, profile, done) => {
    console.log(profile.id);
    console.log(profile.accent_color);
}));

routes/auth.js

const express = require('express');
const router = express.Router();
const passport = require('passport');

/* GET users listing. */
router.get('/', passport.authenticate('discord'));

router.get('/redirect', passport.authenticate('discord', {
    failureRedirect: '/forbidden'
}), function(req, res) {
    res.send(200) // Successful auth
});

module.exports = router;

config/default.json

{
    "apiName": "Discord Profiler API",
    "discord": {
        "clientID": "xxx-xxx-xxx-xxx-xxx-xxx",
        "clientSecret": "xxxxxxxxxxxxxxxxxxx",
        "redirectURL": "localhost:9999/auth/redirect"
    },
    "port": 9999
}

The steps when debugging my project where:

  1. Hitting the route /auth in my browser
  2. It takes me to the Discord Authorization page (typically)
  3. Clicking the authorize button leads me to this page;

Error gotten from Discord authorization page redirect

But I have defined all the routes and test them to see if they work, and they all do. If your curious about the YouTube video I got this from this is the link

about 4 years ago ยท Juan Pablo Isaza
2 answers
Answer question

0

I know I'm late, but always make sure you add "http://" before the localhost and it should work!!

It must be http and not https since its a local address and can't have a SSL certificate

about 4 years ago ยท Juan Pablo Isaza Report

0

Can you check if you're missing the scheme part? it should be http://localhost:9999/auth/redirect

about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!