const encodedHeader = Buffer.from(
`${process.env.REDDIT_CLIENT_ID}:${process.env.REDDIT_CLIENT_SECRET}`,
).toString('base64');
const response = await fetch(`https://www.reddit.com/api/v1/access_token`, {
method: 'POST',
body: `grant_type=authorization_code&code=${code}&redirect_uri=http://localhost:5173/auth/reddit/callback`,
headers: {
authorization: `Basic ${encodedHeader}`,
'Content-Type': 'application/x-www-form-urlencoded',
'User
headers: {
authorization: `Basic ${encodedHeader}`,
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': process.env.REDDIT_USER_AGENT || '',
},
});
const body = await response.json();
console.log(body);
< /code>
Я пытаюсь аутентифицировать Reddit с помощью моего приложения ReactJS, но я получаю 401 на этом вызове API, любые ресурсы, на которые я могу ссылаться?>
Подробнее здесь: https://stackoverflow.com/questions/796 ... eddit-auth