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.