Already an hour I can not perform community authorization. I do this with the new VK SDK:
<?php require ('vendor/autoload.php'); ini_set('error_reporting', E_ALL); /** * Created by PhpStorm. * User: root * Date: 27.04.18 * Time: 11:31 */ use VK\{ Client\VKApiClient, Exceptions\VKClientException, Exceptions\VKOAuthException, OAuth\Scopes\VKOAuthGroupScope, OAuth\VKOAuth, OAuth\VKOAuthDisplay, OAuth\VKOAuthResponseType }; $vk = new VKApiClient(); $oauth = new VKOAuth(); $client_id = %id приложения%; $redirect_uri = 'localhost/provzn_cover'; $display = VKOAuthDisplay::POPUP; $scope = [VKOAuthGroupScope::MANAGE]; $groups_ids = [%id групп%]; $client_secret = %секретный ключ%; if (!isset($_GET['code'])) { $browser_url = $oauth->getAuthorizeUrl(VKOAuthResponseType::CODE, $client_id, $redirect_uri, $display, $scope, null, $groups_ids); header('Location:'.$browser_url); } else { $code = $_GET['code']; try { $response = $oauth->getAccessToken($client_id, $client_secret, $redirect_uri, $code); } catch (VKClientException $e) { die($e->getMessage()); } catch (VKOAuthException $e) { die($e->getMessage()); } $access_token = $response['access_token']; } I get the following error:
Invalid http status: 401 If you manually go to the generated URL, the following is displayed:
{ "error": "invalid_grant", "error_description": "Code is invalid or expired." } Nowhere can I find information about this error and how to fix it. Who can help?