Hello,
I am trying to implement the oAuth2 flow using Node.js to enable my users to connect their Patreon account to my site to prove they are indeed paying. I am following the oAuth implementation guide but at step 4 the only response I get from the API is
{ error: 'unsupported_grant_type' }
My code is
const response = await fetch("https://www.patreon.com/api/oauth2/token", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-encoded" },
body:
"code=" +
code +
"&grant_type=authorization_code&client_id=" +
PA_APP_ID +
"&client_secret=" +
PA_APP_SECRET +
"&redirect_url=" +
PA_CALLBACK,
});
All the variables are set correctly and according to the docs the required grant type is indeed “authorization_code”. So … what am I doing wrong? I have done several other oAuth implementations and this is the only time an API gives me a headache.
Thanks, Richard