question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ApiError: Application authorization failed: access_token has expired

See original GitHub issue

Здравствуйте. Столкнулся с ошибкой: Application authorization failed: access_token has expired.

Как получил:

  1. Делаю запрос серверной авторизации для своего приложения;
  2. Получаю token и пишу его в глобальный объект методом .setToken(access_token);
  3. После этого делаю запрос 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:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nsklyarovcommented, Sep 27, 2017

С помощью метода setToken из вашей библиотеки. Не расширил, точнее будет сказать записал значение сервисного ключа из настроек приложения в вк, в базовый класс предоставляемый библиотекой. Секрет в том, что для некоторых методов vk api, не требуется динамической авторизации она же метод server(), она же Client credentials flow. При попытке использовать метод wall get, с помощью свежего токена - вконтакте плюется ошибкой. При использовании токена из настроек приложения - работает корректно.

0reactions
negezorcommented, Oct 21, 2017

image Вообщем это не баг, а фича.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found