Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

87
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda