Here the code for my OAuth
const redirect_uri = "http://localhost:5000/strtrf/us-central1/api/patreon/validate";
app.get('/', (req, res) => {
res.json({message: "welcome to the startref api"})
})
app.get('/patreon', (req, res) => {
res.redirect('https://www.patreon.com/oauth2/authorize?' +
querystring.stringify({
response_type: 'code',
client_id: env.patreon.id,
redirect_uri
}))
})
app.get('/patreon/validate', (req, res) => {
let code = req.query.code || null
let options = {
headers: {
'Content-Type' : 'application/x-www-form-urlencoded'
}
}
axios.post('https://www.patreon.com/api/oauth2/token',
{
code: code,
redirect_uri,
grant_type: "authorization_code",
client_id: env.patreon.id,
client_secret: env.patreon.secret
}, options)
.then(patreon_res => {
var access_token = patreon_res.data.access_token;
let uri = env.patreon.frontend_uri || 'http://localhost:3000';
res.redirect(uri + '?access_token=' + access_token);
}).catch(err => {
console.log(err);
})
})
I’m having trouble with step 4 in the docs
I’m getting this error { error: 'unsupported_grant_type' }
What am I doing wrong here?