I am trying to create a LINE login authentication function on my web. The problem I am encountering is that I kept receiving error 400, a bad request which may have something to do with the parameter I've put in.
Here is my code,
fetch('https://api.line.me/v2/oauth/accessToken', {
method: 'POST',
mode: 'no-cors',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: JSON.stringify({
grant_type: 'authorization_code',
client_id: 'my_id',
client_secret: 'my_client_secret',
code: code,
redirect_uri: 'the link direct to'
})
}).then(response => {
console.log(response);
}).catch(function(err) {
console.log(err);
});
I followed the reference from LINE, https://developers.line.me/web-api/managing-access-tokens and put in the parameter it asked for, but I kept having the same error.
Tried with postman and got the same error
I am not sure which part I did wrong. Would someone help me with this issue?
JSON.stringify(response)it - Samuel Toh