Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

514
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda