Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const encodeForm = data => {
- return Object.keys(data)
- .map(
- key => encodeURIComponent(key) + "=" + encodeURIComponent(data[key])
- )
- .join("&");
- };
- const creds = await btoa(
- `${process.env.DISCORD_CLIENT_ID}:${process.env.DISCORD_CLIENT_SECRET}`
- );
- const redirect = encodeURIComponent("http://localhost:8080/");
- const formData = {
- grant_type: "authorization_code",
- code: code,
- redirect_uri: redirect,
- scope: "identify"
- };
- axios.post(
- `https://discordapp.com/api/oauth2/token`,
- encodeForm(formData),
- {
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- Authorization: `Basic ${creds}`
- }
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement