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

508
Visualizações
how to delete github oauth accessToken when user logout?

I'm having trouble with deleting github accessToken when user try to logout from my react app. I was trying to follow the instructions in github delete accesstoken documents, but I get an 404 bad request.

I was trying to handle github logout by javascript in React App. Here's the code.

const handleGithubLogout = async() => {
        
        await axios.delete('https://api.github.com/applications/${mygithubClientId}/token',
            {data : {access_token:"${mygithubAccessToken}"}}
            ,
            {headers: {
                    Accept: "application/vnd.github.v3+json",
                }
        })
        .then((data) => {
            console.log('succceed')
        })
        
        setTimeout(() => purge(), 100)

    }

The thing is ,in github document, they described how to delete github accessToken by cURL and javascript.

curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/applications/Iv1.8a61f9b3a7aba766/token \
  -d '{"access_token":"e72e16c7e42f292c6912e7710c838347ae178b4a"}'

so I tried javascript code like below. but still gets the 404 response.

const octokit = new Octokit({
             auth: '${myGithubAccessToken}'
           })
          
          await octokit.request(`DELETE /https://api.github.com/applications/{myClientID}/token`, {
             client_id: myClientID,
             access_token: myGithubAccessToken
           }).then(() => {
               console.log('success')
           })

I wonder how to change cURL code to javascript code. I'm not sure I wrote the code correctly. and also there is the same question in stackoverflow but I still don't get it how it works.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

See the provided javascript example code in the documentation you linked to:

// Octokit.js
// https://github.com/octokit/core.js#readme
const octokit = new Octokit({
  auth: 'personal-access-token123'
})

await octokit.request('DELETE /applications/{client_id}/token', {
  client_id: 'Iv1.8a61f9b3a7aba766',
  access_token: 'e72e16c7e42f292c6912e7710c838347ae178b4a'
})

Compared to that there are multiple issues in your code snippet:

  • auth: '${myGithubAccessToken}' will assign the literal string '${myGithubAccessToken}' and not the value of myGithubAccessToken. Either use template strings with backticks or no quoting at all: auth: myGithubAccessToken
  • the request URL specified is a domain-relative URL containing another absolute URL, i.e. it will be resolved to https://api.github.com/https://api.github.com/applications/{myClientID}/token. Either remove the leading / or - as in the example code - leave out the protocol and host part
  • in the URL you specify {myClientID} as placeholder but only pass the client_id, so it won't be replaced properly. You have to use {client_id} instead
about 4 years ago · Juan Pablo Isaza 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