Do you know how to delete github OAuth token API?

Viewed 39

I'm trying to delete the access token after github login authentication, but it doesn't disappear. Does anyone know any solution??

The error text is as follows. Error: Request failed with status code 403 data: 'Cookies must be enabled to use GitHub.'

module.exports = async (req, res) => {
  const accessToken = req.body.accessToken;
  try {
    const response = await axios.delete(
      `https://github.com/applications/${CLIENT_ID}/token`,
      {
        data: {
          // client_id: CLIENT_ID,
          access_token: accessToken,
        },
      }
    );
    res.status(205).send('히히 성공했다 카이');
  } catch (e) {
    console.log('에러');
    console.log(e);
  }
};
1 Answers

Yes, you need to add an auth object (with your client_id and secret as username & passsword) to the axios options:

Ex:

  let ghRes
  try {
    ghRes = await axios.delete(url,
    {         
      auth: { 
       username: clientID, 
       password: clientSecret 
      }, 
      headers: {
        Accept: 'application/vnd.github+json', 
        Authorization: 'token ' + accessToken
      },  
      data = { 
        access_token : accessToken 
      }  
    })  
  } catch (err) { log(err) } 

(also encountered this trip-up and had to dig for a while)

Related