Skip to content

Commit

Permalink
Merge pull request #33 from bocharsky-bw/instagram
Browse files Browse the repository at this point in the history
Add Instagram provider
  • Loading branch information
weaverryan authored Aug 2, 2016
2 parents d1b10e5 + 28fa3b2 commit 1e24683
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 8 deletions.
27 changes: 27 additions & 0 deletions Client/Provider/InstagramClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace KnpU\OAuth2ClientBundle\Client\Provider;

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

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

/**
* @return InstagramResourceOwner
*/
public function fetchUser()
{
return parent::fetchUser();
}
}
1 change: 1 addition & 0 deletions DependencyInjection/KnpUOAuth2ClientExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class KnpUOAuth2ClientExtension extends Extension
'linkedin' => 'KnpU\OAuth2ClientBundle\DependencyInjection\Providers\LinkedInProviderConfigurator',
'google' => 'KnpU\OAuth2ClientBundle\DependencyInjection\Providers\GoogleProviderConfigurator',
'eve_online' => 'KnpU\OAuth2ClientBundle\DependencyInjection\Providers\EveOnlineProviderConfigurator',
'instagram' => 'KnpU\OAuth2ClientBundle\DependencyInjection\Providers\InstagramProviderConfigurator',
'generic' => 'KnpU\OAuth2ClientBundle\DependencyInjection\Providers\GenericProviderConfigurator'
);

Expand Down
48 changes: 48 additions & 0 deletions DependencyInjection/Providers/InstagramProviderConfigurator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace KnpU\OAuth2ClientBundle\DependencyInjection\Providers;

use KnpU\OAuth2ClientBundle\Client\Provider\InstagramClient;
use League\OAuth2\Client\Provider\Instagram;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

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

public function getProviderClass(array $config)
{
return Instagram::class;
}

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

public function getPackagistName()
{
return 'league/oauth2-instagram';
}

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

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

public function getClientClass(array $config)
{
return InstagramClient::class;
}
}
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ via Composer:

<a name="client-downloader-table"></a>

| OAuth2 Provider | Install |
| ------------------------------------------------------------ | ------------------------------------------ |
| [Facebook](https://github.com/thephpleague/oauth2-facebook) | composer require league/oauth2-facebook |
| [GitHub](https://github.com/thephpleague/oauth2-github) | composer require league/oauth2-github |
| [LinkedIn](https://github.com/thephpleague/oauth2-linkedin) | composer require league/oauth2-linkedin |
| [Google](https://github.com/thephpleague/oauth2-google) | composer require league/oauth2-google |
| [Eve Online](https://github.com/evelabs/oauth2-eveonline) | composer require evelabs/oauth2-eveonline |
| generic | configure any unsupported provider |
| OAuth2 Provider | Install |
| -------------------------------------------------------------- | ------------------------------------------ |
| [Facebook](https://github.com/thephpleague/oauth2-facebook) | composer require league/oauth2-facebook |
| [GitHub](https://github.com/thephpleague/oauth2-github) | composer require league/oauth2-github |
| [LinkedIn](https://github.com/thephpleague/oauth2-linkedin) | composer require league/oauth2-linkedin |
| [Google](https://github.com/thephpleague/oauth2-google) | composer require league/oauth2-google |
| [Eve Online](https://github.com/evelabs/oauth2-eveonline) | composer require evelabs/oauth2-eveonline |
| [Instagram](https://github.com/thephpleague/oauth2-instagram) | composer require league/oauth2-instagram |
| generic | configure any unsupported provider |

<span name="end-client-downloader-table"></span>

Expand Down Expand Up @@ -390,6 +391,22 @@ knpu_oauth2_client:
redirect_route: connect_eve_online_check
redirect_params: {}
# whether to check OAuth2 "state": defaults to true
# use_state: true
# will create service: "knpu.oauth2.client.instagram"
# an instance of: KnpU\OAuth2ClientBundle\Client\Provider\InstagramClient
# composer require league/oauth2-instagram
instagram:
# must be "instagram" - it activates that type!
type: instagram
# add and configure client_id and client_secret in parameters.yml
client_id: %instagram_client_id%
client_secret: %instagram_client_secret%
# a route name you'll create
redirect_route: connect_instagram_check
redirect_params: {}
# whether to check OAuth2 "state": defaults to true
# use_state: true
```
Expand Down

0 comments on commit 1e24683

Please sign in to comment.