Skip to content

Commit

Permalink
Merge pull request #42 from fatihkahveci/vk-provider
Browse files Browse the repository at this point in the history
VKontakte provider added
  • Loading branch information
weaverryan authored Jan 9, 2017
2 parents 3473596 + 86201da commit b117f4d
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Client/Provider/VKontakteClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/*
* OAuth2 Client Bundle
* Copyright (c) KnpUniversity <http://knpuniversity.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace KnpU\OAuth2ClientBundle\Client\Provider;

use KnpU\OAuth2ClientBundle\Client\OAuth2Client;
use J4k\OAuth2\Client\Provider\User;
use League\OAuth2\Client\Token\AccessToken;

class VKontakteClient extends OAuth2Client
{
/**
* @param AccessToken $accessToken
* @return User
*/
public function fetchUserFromToken(AccessToken $accessToken)
{
return parent::fetchUserFromToken($accessToken);
}

/**
* @return User
*/
public function fetchUser()
{
return parent::fetchUser();
}
}
2 changes: 2 additions & 0 deletions src/DependencyInjection/KnpUOAuth2ClientExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\InstagramProviderConfigurator;
use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\LinkedInProviderConfigurator;
use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\ProviderConfiguratorInterface;
use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\VKontakteProviderConfigurator;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
Expand Down Expand Up @@ -47,6 +48,7 @@ class KnpUOAuth2ClientExtension extends Extension
'google' => GoogleProviderConfigurator::class,
'eve_online' => EveOnlineProviderConfigurator::class,
'instagram' => InstagramProviderConfigurator::class,
'vkontakte' => VKontakteProviderConfigurator::class,
'bitbucket' => BitbucketProviderConfigurator::class,
'generic' => GenericProviderConfigurator::class,
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/*
* OAuth2 Client Bundle
* Copyright (c) KnpUniversity <http://knpuniversity.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace KnpU\OAuth2ClientBundle\DependencyInjection\Providers;

use Symfony\Component\Config\Definition\Builder\NodeBuilder;

class VKontakteProviderConfigurator implements ProviderConfiguratorInterface
{
public function buildConfiguration(NodeBuilder $node)
{
// no custom options
}

public function getProviderClass(array $config)
{
return 'J4k\OAuth2\Client\Provider\Vkontakte';
}

public function getProviderOptions(array $config)
{
return [
'clientId' => $config['client_id'],
'clientSecret' => $config['client_secret'],
];
}

public function getPackagistName()
{
return 'j4k/oauth2-vkontakte';
}

public function getLibraryHomepage()
{
return 'https://github.com/j4k/oauth2-vkontakte';
}

public function getProviderDisplayName()
{
return 'VKontakte';
}

public function getClientClass(array $config)
{
return 'KnpU\OAuth2ClientBundle\Client\Provider\VKontakteClient';
}
}

0 comments on commit b117f4d

Please sign in to comment.