Search code examples
symfonyvkhwioauthbundle

HWIOAuthBundle 'Cannot register an account.' with social VK


I have problem with HWIOAuthBundle and vk.com, everything works, but some time ago I found face to face with error, after oAuth with vk.com

'Cannot register an account.'

I found this place vendor/hwi/oauth-bundle/Controller/ConnectController.php:106

        if (!($error instanceof AccountNotLinkedException) || (time() - $key > 300)) {
        // todo: fix this
        throw new \Exception('Cannot register an account.');
    }

But not understand why it's happens. I try to use another apps but it's not help. Maybe somebody knows why I got this error ?


Solution

  • you must specify version 3.0 api VK in vendor/hwi/oauth-bundle/OAuth/ResourceOwner/VkontakteResourceOwner.php

    public function getUserInformation(array $accessToken, array $extraParameters = array())
    {
        $url = $this->normalizeUrl($this->options['infos_url'], array(
            'access_token' => $accessToken['access_token'],
            'fields'       => $this->options['fields'],
            'name_case'    => $this->options['name_case'],
            'v'            => '3.0'
        ));
    
        $content = $this->doGetUserInformationRequest($url)->getContent();
    
    
    
        $response = $this->getUserResponse();
        $response->setResponse($content);
        $response->setResourceOwner($this);
        $response->setOAuthToken(new OAuthToken($accessToken));
    
        $content = $response->getResponse();
        $content['email'] = isset($accessToken['email']) ? $accessToken['email'] : null;
        if (isset($content['screen_name'])) {
            $content['nickname'] = $content['screen_name'];
        } else {
            $content['nickname'] = isset($content['nickname']) ? $content['nickname'] : null;
        }
    
        $response->setResponse($content);
    
        return $response;
    }