ApiError: Application authorization failed: access_token has expired
See original GitHub issueЗдравствуйте. Столкнулся с ошибкой: Application authorization failed: access_token has expired.
Как получил:
- Делаю запрос серверной авторизации для своего приложения;
- Получаю token и пишу его в глобальный объект методом .setToken(access_token);
- После этого делаю запрос wall.get;
Ожидаемый результат: Объект соответствующий параметрам запроса. Фактический результат:
{ ApiError: Application authorization failed: access_token has expired.
name: 'ApiError',
code: 28,
params:
[ { key: 'oauth', value: '1' },
{ key: 'method', value: 'wall.get' },
{ key: 'lang', value: '' },
{ key: 'v', value: '5.68' },
{ key: 'owner_id', value: '-86529522' },
{ key: 'count', value: '1' },
{ key: 'filter', value: 'owner' },
{ key: 'extended', value: '1' } ] }
Такая ошибка повторяется и при использовании других методов, users.get, например, после использования метода .setToken(access_token);
const vkClient = new VK({
app: vk.appId,
key: vk.key
});
const auth = _ => vkClient.auth
.server()
.then(token => Promise.resolve(vkClient.setToken(token)));
auth()
.then(client => {
return client.api.wall.get({
owner_id: '-86529522',
count: 1,
filter: 'owner',
extended: 1
})
})
.then(response => console.log(response))
.catch((error) => {
console.error(error);
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Token Expired - JSON REST API - Error Code - Stack Overflow
The resource SHOULD respond with the HTTP 401 (Unauthorized) status code. The client MAY request a new access token and retry the protected...
Read more >'401 Unauthorized HTTP' for REST API token that expires in ...
Error : '401 Unauthorized HTTP' for REST API token that expires in less than 60 minutes. ... When this happens, you'll need to...
Read more >Best practices for API error handling and troubleshooting
When requesting an OAuth access token using the POST /token operation, your application shall exploit the 'expire_in' field that provides the ...
Read more >Authorization Errors | Device Access - Google Developers
When attempting to get an access or refresh token, you will get an "Invalid client" error if you provide an incorrect OAuth 2.0...
Read more >Meta for Developers | How-To: Handle expired access tokens
What many developers do not realize is that an access token can also expire if a ... "Error validating access token: USER_ID has...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
С помощью метода setToken из вашей библиотеки. Не расширил, точнее будет сказать записал значение сервисного ключа из настроек приложения в вк, в базовый класс предоставляемый библиотекой. Секрет в том, что для некоторых методов vk api, не требуется динамической авторизации она же метод server(), она же Client credentials flow. При попытке использовать метод wall get, с помощью свежего токена - вконтакте плюется ошибкой. При использовании токена из настроек приложения - работает корректно.