From aad9377d3ed648e4c082d8cdb500ac4a4c8939ce Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Sun, 24 Jul 2016 23:29:19 +0300 Subject: [PATCH 1/6] Bootstrap Instagram provider files --- Client/Provider/InstagramClient.php | 28 +++++++++++ .../InstagramProviderConfigurator.php | 48 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 Client/Provider/InstagramClient.php create mode 100644 DependencyInjection/Providers/InstagramProviderConfigurator.php diff --git a/Client/Provider/InstagramClient.php b/Client/Provider/InstagramClient.php new file mode 100644 index 00000000..7e682ecc --- /dev/null +++ b/Client/Provider/InstagramClient.php @@ -0,0 +1,28 @@ + $config['clientId'], + 'clientSecret' => $config['clientSecret'], + ); + } + + 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; + } +} From bb189679812f89fac33747b02f170877132e0abc Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Fri, 29 Jul 2016 23:36:30 +0300 Subject: [PATCH 2/6] Remove unnecessary class in PHP doc-block --- Client/Provider/InstagramClient.php | 3 +-- composer.json | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Client/Provider/InstagramClient.php b/Client/Provider/InstagramClient.php index 7e682ecc..f0a9fd9a 100644 --- a/Client/Provider/InstagramClient.php +++ b/Client/Provider/InstagramClient.php @@ -4,7 +4,6 @@ use KnpU\OAuth2ClientBundle\Client\OAuth2Client; use League\OAuth2\Client\Provider\InstagramResourceOwner; -use League\OAuth2\Client\Provider\ResourceOwnerInterface; use League\OAuth2\Client\Token\AccessToken; class InstagramClient extends OAuth2Client @@ -19,7 +18,7 @@ public function fetchUserFromToken(AccessToken $accessToken) } /** - * @return InstagramResourceOwner|ResourceOwnerInterface + * @return InstagramResourceOwner */ public function fetchUser() { diff --git a/composer.json b/composer.json index 56e391c8..7fa072ee 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ "symfony/dependency-injection": "~2.8|~3.0", "symfony/routing": "~2.3|~3.0", "symfony/http-foundation": "~2.4|~3.0", - "league/oauth2-client": "^1.0" + "league/oauth2-client": "^1.0", + "league/oauth2-instagram": "^0.2.2" }, "autoload": { "psr-4": { "KnpU\\OAuth2ClientBundle\\": "" } From 514bbd06c5a32087a9ef174ea3ad0f28700c75ad Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Fri, 29 Jul 2016 23:45:57 +0300 Subject: [PATCH 3/6] Add Instagram provider to the supported list --- DependencyInjection/KnpUOAuth2ClientExtension.php | 1 + 1 file changed, 1 insertion(+) diff --git a/DependencyInjection/KnpUOAuth2ClientExtension.php b/DependencyInjection/KnpUOAuth2ClientExtension.php index 4bdd566b..2da52e28 100644 --- a/DependencyInjection/KnpUOAuth2ClientExtension.php +++ b/DependencyInjection/KnpUOAuth2ClientExtension.php @@ -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' ); From 3e9688552aef16c90fb199266967e98f876d7182 Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Fri, 29 Jul 2016 23:50:24 +0300 Subject: [PATCH 4/6] Generate docs for Instagram provider --- README.md | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 47440244..5cafd116 100644 --- a/README.md +++ b/README.md @@ -50,14 +50,15 @@ via Composer: -| 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 | @@ -386,6 +387,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 ``` From b9d671c163be4f08a414bbfd598dd5a039b47aba Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Sat, 30 Jul 2016 00:37:22 +0300 Subject: [PATCH 5/6] Revert adding instagram oauth lib as Composer dependency --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7fa072ee..56e391c8 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,7 @@ "symfony/dependency-injection": "~2.8|~3.0", "symfony/routing": "~2.3|~3.0", "symfony/http-foundation": "~2.4|~3.0", - "league/oauth2-client": "^1.0", - "league/oauth2-instagram": "^0.2.2" + "league/oauth2-client": "^1.0" }, "autoload": { "psr-4": { "KnpU\\OAuth2ClientBundle\\": "" } From 28fa3b293846c3027aed1d52aff6e8bad09b68ab Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Sun, 31 Jul 2016 23:45:32 +0300 Subject: [PATCH 6/6] Fix name of config keys --- .../Providers/InstagramProviderConfigurator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Providers/InstagramProviderConfigurator.php b/DependencyInjection/Providers/InstagramProviderConfigurator.php index c8d210b2..002c9d16 100644 --- a/DependencyInjection/Providers/InstagramProviderConfigurator.php +++ b/DependencyInjection/Providers/InstagramProviderConfigurator.php @@ -21,8 +21,8 @@ public function getProviderClass(array $config) public function getProviderOptions(array $config) { return array( - 'clientId' => $config['clientId'], - 'clientSecret' => $config['clientSecret'], + 'clientId' => $config['client_id'], + 'clientSecret' => $config['client_secret'], ); }