Я получил токен, авторизовав пользователя с помощью этого URL:
const fetch = require('node-fetch');
const VK_CLIENT_ID = '1231231';
const photos = 4;
const wall = 8192;
const offline = 65536;
const scope = offline + wall + photos;
const URL = `https://oauth.vk.com/authorize?client_id=${VK_CLIENT_ID}&display=popup&redirect_uri=http://example.com/auth/vk&scope=${scope}&response_type=token&v=5.78`;
const accessToken = '...';
const ownerID = '212121212';
fetch(
`https://api.vk.com/method/wall.post?v=5.78&message=test_api&owner_id=${ownerID}&access_token=${accessToken}`
)
.then(res => res.text())
.then(body => console.log(body));
Ошибка:
{
error: {
error_code: 15,
error_msg: "Access denied: no access to call this method",
request_params: [
{ key: "oauth", value: "1" },
{ key: "method", value: "wall.post" },
{ key: "v", value: "5.78" },
{ key: "message", value: "test_api" },
{ key: "owner_id", value: "184591202" }
]
}
}