Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
An easy snippet to generate your Discord bot's Bearer token!
const express = require('express');
const app = express();
const fetch = require('node-fetch');
const client_id = 'CLIENT_UI'; //can be found in the developer portal
const redirect_uri = 'http://localhost:8000/home';
const client_secret = 'CLIENT_SECRET'; //can be also found in the developer portal
const scope = 'identify'; // set the redirect_uri in your OAuth2 section and use the identify scope in your browser.
app.get('/authorize', (req, res) => {
app.get('/home', async (req, res) => {
fetch('', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
body: new URLSearchParams({
client_id: client_id,
client_secret: client_secret,
code: req.query.code,
grant_type: 'authorization_code',
redirect_uri: redirect_uri,
scope: scope,
.then(response => response.json())
.then((data) => console.log(data));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment