Here is the code I'm using, but I keep getting a 403 error in response.
let username = "CLIENT_ID_GOES_HERE";
let password = "SECRET_GOES_HERE";
let basicAuth = Buffer.from(`${username}:${password}`).toString('base64');
try {
response = await axios.delete(`https://github.com/applications/${clientId}/grant`,
{
headers: {
'Authorization': `Basic ${basicAuth}`,
'Accept': 'application/vnd.github.v3 json',
},
data: {
access_token: token
}
});
} catch (e) {
return {
statusCode: 502,
body: JSON.stringify(e)
}
}
I've verified that the client ID, secret and token are all correct. The token I'm using is the one that is returned by github upon authenticating.
CodePudding user response:
Check if, as in here, a token authorization header would work better:
Authorization: `token ${process.env.GITHUB_TOKEN}`,
CodePudding user response:
I figured it out. First, I had to modify my axios request to be able to see the full error message. Inside the 'catch' part of a try-catch, I was able to take a look at the value of error.response.data
.
The error I was getting was "Cookies must be enabled to use github".
After some Googling, someone with the same error commented that they had to use the host api.github.com
. Turns out that I was using github.com
. Once I changed this, the error went away.