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

79
Views
Discord api get guild

I'm trying to fetch my guild info from discord API

fetch('https://discord.com/api/guilds/772037458996101140', {
            headers: {
                authorization: 'bot Nzc******zNjYzOTAz.GPwhCV.rhIcH****5R8ZS-cIo4MjPcBVxO6wYsUXhY'
            },
        })
            .then(result => result.json())
            .then(response => {
                console.log(response);
            })
            .catch(console.error)

only reciving 401 (unauthorized)

i tried changing "bot" to "BOT", "Bot", "Bearer" and doing authorization using access token from Oauth2

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

The problem lies in how the Authorization header has been specified. The correct way specify headers would be:


fetch('https://discord.com/api/guilds/772037458996101140', {
            withCredentials: true,
            credentials: 'include',
            headers: {
            'Authorization': 'bot Nzc******zNjYzOTAz.GPwhCV.rhIcH****5R8ZS-cIo4MjPcBVxO6wYsUXhY',
            },
        })
            .then(result => result.json())
            .then(response => {
                console.log(response);
            })
            .catch(console.error)

Hope this helps.

Edit

Also added crendentials and withCredentials based on this answer.

about 4 years ago · Santiago Trujillo Report

0

I was sending http request from front-end and when i moved it to back-end or just used python test file it worked using : Authorization: 'Bot <TOKEN>'

not sure why but it works how it should mby somebody can explain ?

about 4 years ago · Santiago Trujillo 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!