Comments (6)
Hi All
This issue is caused by the upgrade in Discord's OAuth API. If you look at the official documentation, it clearly outlines that you now need to use content type of x-www-form-urlencoded: https://discord.com/developers/docs/topics/oauth2
For nodejs implementation you can follow this guide: https://discordjs.guide/oauth2/#oauth2-flows
Changes
Existing code:
const creds = btoa(`${CLIENT_ID}:${CLIENT_SECRET}`);
const response = await fetch(`https://discordapp.com/api/oauth2/token?grant_type=authorization_code&code=${code}&redirect_uri=${redirect}`,
{
method: 'POST',
headers: {
Authorization: `Basic ${creds}`,
},
});
New code
const FormData = require('form-data')
const data = new FormData()
data.append('client_id', CLIENT_ID)
data.append('client_secret', CLIENT_SECRET)
data.append('grant_type', 'authorization_code')
data.append('redirect_uri', REDIRECT_URI)
data.append('scope', 'identify email')
data.append('code', code)
const response = await fetch('https://discordapp.com/api/oauth2/token', {
method: 'POST',
body: data,
})
from discord-token-generator.
Can confirm.. same here
from discord-token-generator.
Was shown this in the Discord API server
from discord-token-generator.
Hi All
This issue is caused by the upgrade in Discord's OAuth API. If you look at the official documentation, it clearly outlines that you now need to use content type of x-www-form-urlencoded: https://discord.com/developers/docs/topics/oauth2
For nodejs implementation you can follow this guide: https://discordjs.guide/oauth2/#oauth2-flows
Changes
Existing code:
const creds = btoa(`${CLIENT_ID}:${CLIENT_SECRET}`); const response = await fetch(`https://discordapp.com/api/oauth2/token?grant_type=authorization_code&code=${code}&redirect_uri=${redirect}`, { method: 'POST', headers: { Authorization: `Basic ${creds}`, }, });
New code
const FormData = require('form-data') const data = new FormData() data.append('client_id', CLIENT_ID) data.append('client_secret', CLIENT_SECRET) data.append('grant_type', 'authorization_code') data.append('redirect_uri', REDIRECT_URI) data.append('scope', 'identify email') data.append('code', code) const response = await fetch('https://discordapp.com/api/oauth2/token', { method: 'POST', body: data, })
What to do?
Error: {"status":"ERROR","error":"REDIRECT_URI is not defined"}
from discord-token-generator.
Hi All
This issue is caused by the upgrade in Discord's OAuth API. If you look at the official documentation, it clearly outlines that you now need to use content type of x-www-form-urlencoded: https://discord.com/developers/docs/topics/oauth2
For nodejs implementation you can follow this guide: https://discordjs.guide/oauth2/#oauth2-flows
Changes
Existing code:
const creds = btoa(`${CLIENT_ID}:${CLIENT_SECRET}`); const response = await fetch(`https://discordapp.com/api/oauth2/token?grant_type=authorization_code&code=${code}&redirect_uri=${redirect}`, { method: 'POST', headers: { Authorization: `Basic ${creds}`, }, });
New code
const FormData = require('form-data') const data = new FormData() data.append('client_id', CLIENT_ID) data.append('client_secret', CLIENT_SECRET) data.append('grant_type', 'authorization_code') data.append('redirect_uri', REDIRECT_URI) data.append('scope', 'identify email') data.append('code', code) const response = await fetch('https://discordapp.com/api/oauth2/token', { method: 'POST', body: data, })
It still does not work. . .
from discord-token-generator.
Hey all, I answered this in #11!
from discord-token-generator.
Related Issues (14)
- Unable to start server HOT 2
- token undefinedx HOT 1
- token undefined HOT 15
- missisng redirect uri in request HOT 1
- Invalid OAuth2 redirect_uri HOT 1
- Self work
- Hhhh
- help needed quick HOT 2
- Updated Version? HOT 1
- Please Help! HOT 1
- CLIENT_ID is not snowflake HOT 9
- HELP HOT 4
- Thx
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from discord-token-generator.