Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon, Fitbit, Heroku, Paypal, Stripe Clients added #63

Merged
merged 14 commits into from
Nov 2, 2017
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ via Composer:

| OAuth2 Provider | Install |
| --------------------------------------------------------------------- | ------------------------------------------------------ |
| [Amazon](https://github.com/luchianenco/oauth2-amazon) | composer require luchianenco/oauth2-amazon |
| [Auth0](https://github.com/RiskioFr/oauth2-auth0) | composer require riskio/oauth2-auth0 |
| [Azure](https://github.com/thenetworg/oauth2-azure) | composer require thenetworg/oauth2-azure |
| [Bitbucket](https://github.com/stevenmaguire/oauth2-bitbucket) | composer require stevenmaguire/oauth2-bitbucket |
Expand All @@ -65,15 +66,19 @@ via Composer:
| [Drupal](https://github.com/chrishemmings/oauth2-drupal) | composer require chrishemmings/oauth2-drupal |
| [Eve Online](https://github.com/evelabs/oauth2-eveonline) | composer require evelabs/oauth2-eveonline |
| [Facebook](https://github.com/thephpleague/oauth2-facebook) | composer require league/oauth2-facebook |
| [Fitbit](https://github.com/djchen/oauth2-fitbit) | composer require djchen/oauth2-fitbit |
| [HeadHunter](https://github.com/AlexMasterov/oauth2-headhunter) | composer require alexmasterov/oauth2-headhunter |
| [Heroku](https://github.com/stevenmaguire/oauth2-heroku) | composer require stevenmaguire/oauth2-heroku |
| [Instagram](https://github.com/thephpleague/oauth2-instagram) | composer require league/oauth2-instagram |
| [GitHub](https://github.com/thephpleague/oauth2-github) | composer require league/oauth2-github |
| [GitLab](https://github.com/omines/oauth2-gitlab) | composer require omines/oauth2-gitlab |
| [Google](https://github.com/thephpleague/oauth2-google) | composer require league/oauth2-google |
| [LinkedIn](https://github.com/thephpleague/oauth2-linkedin) | composer require league/oauth2-linkedin |
| [Microsoft](https://github.com/stevenmaguire/oauth2-microsoft) | composer require stevenmaguire/oauth2-microsoft |
| [Odnoklassniki](https://github.com/rakeev/oauth2-odnoklassniki) | composer require aego/oauth2-odnoklassniki |
| [Paypal](https://github.com/stevenmaguire/oauth2-paypal) | composer require stevenmaguire/oauth2-paypal |
| [Slack](https://github.com/adam-paterson/oauth2-slack) | composer require adam-paterson/oauth2-slack |
| [Stripe](https://github.com/adam-paterson/oauth2-stripe) | composer require adam-paterson/oauth2-stripe |
| [Vimeo](https://github.com/saf33r/oauth2-vimeo) | composer require saf33r/oauth2-vimeo |
| [VKontakte](https://github.com/j4k/oauth2-vkontakte) | composer require j4k/oauth2-vkontakte |
| [Yahoo](https://github.com/hayageek/oauth2-yahoo) | composer require hayageek/oauth2-yahoo |
Expand Down Expand Up @@ -326,6 +331,22 @@ any provider.
# app/config/config.yml
knpu_oauth2_client:
clients:
# will create service: "knpu.oauth2.client.amazon"
# an instance of: KnpU\OAuth2ClientBundle\Client\Provider\AmazonClient
# composer require luchianenco/oauth2-amazon
amazon:
# must be "amazon" - it activates that type!
type: amazon
# add and configure client_id and client_secret in parameters.yml
client_id: %amazon_client_id%
client_secret: %amazon_client_secret%
# a route name you'll create
redirect_route: connect_amazon_check
redirect_params: {}

# whether to check OAuth2 "state": defaults to true
# use_state: true

# will create service: "knpu.oauth2.client.auth0"
# an instance of: KnpU\OAuth2ClientBundle\Client\Provider\Auth0Client
# composer require riskio/oauth2-auth0
Expand Down Expand Up @@ -470,6 +491,22 @@ knpu_oauth2_client:
# whether to check OAuth2 "state": defaults to true
# use_state: true

# will create service: "knpu.oauth2.client.fitbit"
# an instance of: KnpU\OAuth2ClientBundle\Client\Provider\FitbitClient
# composer require djchen/oauth2-fitbit
fitbit:
# must be "fitbit" - it activates that type!
type: fitbit
# add and configure client_id and client_secret in parameters.yml
client_id: %fitbit_client_id%
client_secret: %fitbit_client_secret%
# a route name you'll create
redirect_route: connect_fitbit_check
redirect_params: {}

# whether to check OAuth2 "state": defaults to true
# use_state: true

# will create service: "knpu.oauth2.client.headhunter"
# an instance of: KnpU\OAuth2ClientBundle\Client\Provider\HeadHunterClient
# composer require alexmasterov/oauth2-headhunter
Expand All @@ -486,6 +523,22 @@ knpu_oauth2_client:
# whether to check OAuth2 "state": defaults to true
# use_state: true

# will create service: "knpu.oauth2.client.heroku"
# an instance of: KnpU\OAuth2ClientBundle\Client\Provider\HerokuClient
# composer require stevenmaguire/oauth2-heroku
heroku:
# must be "heroku" - it activates that type!
type: heroku
# add and configure client_id and client_secret in parameters.yml
client_id: %heroku_client_id%
client_secret: %heroku_client_secret%
# a route name you'll create
redirect_route: connect_heroku_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
Expand Down Expand Up @@ -609,6 +662,23 @@ knpu_oauth2_client:
# whether to check OAuth2 "state": defaults to true
# use_state: true

# will create service: "knpu.oauth2.client.paypal"
# an instance of: KnpU\OAuth2ClientBundle\Client\Provider\PaypalClient
# composer require stevenmaguire/oauth2-paypal
paypal:
# must be "paypal" - it activates that type!
type: paypal
# add and configure client_id and client_secret in parameters.yml
client_id: %paypal_client_id%
client_secret: %paypal_client_secret%
# a route name you'll create
redirect_route: connect_paypal_check
redirect_params: {}
# When true, client uses Paypal Sandbox URLs.
# is_sandbox: false
# whether to check OAuth2 "state": defaults to true
# use_state: true

# will create service: "knpu.oauth2.client.slack"
# an instance of: KnpU\OAuth2ClientBundle\Client\Provider\SlackClient
# composer require adam-paterson/oauth2-slack
Expand All @@ -625,6 +695,22 @@ knpu_oauth2_client:
# whether to check OAuth2 "state": defaults to true
# use_state: true

# will create service: "knpu.oauth2.client.stripe"
# an instance of: KnpU\OAuth2ClientBundle\Client\Provider\StripeClient
# composer require adam-paterson/oauth2-stripe
stripe:
# must be "stripe" - it activates that type!
type: stripe
# add and configure client_id and client_secret in parameters.yml
client_id: %stripe_client_id%
client_secret: %stripe_client_secret%
# a route name you'll create
redirect_route: connect_stripe_check
redirect_params: {}

# whether to check OAuth2 "state": defaults to true
# use_state: true

# will create service: "knpu.oauth2.client.vimeo"
# an instance of: KnpU\OAuth2ClientBundle\Client\Provider\VimeoClient
# composer require saf33r/oauth2-vimeo
Expand Down
6 changes: 6 additions & 0 deletions bin/update_readme
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require __DIR__.'/../vendor/autoload.php';
use KnpU\OAuth2ClientBundle\DependencyInjection\KnpUOAuth2ClientExtension;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ArrayNode;
use Symfony\Component\Config\Definition\BooleanNode;
use Symfony\Component\Config\Definition\NodeInterface;

function replaceInString($startTextMarker, $endTextMarker, $fullText, $replacementText)
Expand Down Expand Up @@ -92,6 +93,11 @@ foreach (KnpUOAuth2ClientExtension::getAllSupportedTypes() as $type) {
// *should* ? come out looking like valid-ish YAML
? json_encode($child->getDefaultValue())
: '{}';

} elseif ($child instanceof BooleanNode) {
$defaultValue = $child->getDefaultValue()
? $child->getDefaultValue()
Copy link
Member

@bocharsky-bw bocharsky-bw Oct 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be simply 'true', otherwise we'll have 1 in README instead

Copy link
Contributor Author

@luchianenco luchianenco Oct 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do u mean : $defaultValue = $child->getDefaultValue() ? 'true'

Copy link
Member

@bocharsky-bw bocharsky-bw Oct 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite, I mean ? 'true' on this line, i.e.:

 $defaultValue = $child->getDefaultValue()
    ? 'true'
    : 'false';

We need true as a string too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's what I meant ;) sorry just shorted the expression :)
ok I will do

: 'false';
} else {
$defaultValue = $child->getDefaultValue()
? $child->getDefaultValue()
Expand Down
34 changes: 34 additions & 0 deletions src/Client/Provider/AmazonClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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 League\OAuth2\Client\Token\AccessToken;
use Luchianenco\OAuth2\Client\Provider\AmazonResourceOwner;

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

/**
* @return AmazonResourceOwner
*/
public function fetchUser()
{
return parent::fetchUser();
}
}
34 changes: 34 additions & 0 deletions src/Client/Provider/FitbitClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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 League\OAuth2\Client\Token\AccessToken;
use djchen\OAuth2\Client\Provider\FitbitUser;

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

/**
* @return FitbitUser
*/
public function fetchUser()
{
return parent::fetchUser();
}
}
34 changes: 34 additions & 0 deletions src/Client/Provider/HerokuClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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 League\OAuth2\Client\Token\AccessToken;
use Stevenmaguire\OAuth2\Client\Provider\HerokuResourceOwner;

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

/**
* @return HerokuResourceOwner
*/
public function fetchUser()
{
return parent::fetchUser();
}
}
34 changes: 34 additions & 0 deletions src/Client/Provider/PaypalClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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 League\OAuth2\Client\Token\AccessToken;
use Stevenmaguire\OAuth2\Client\Provider\PaypalResourceOwner;

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

/**
* @return PaypalResourceOwner
*/
public function fetchUser()
{
return parent::fetchUser();
}
}
34 changes: 34 additions & 0 deletions src/Client/Provider/StripeClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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 League\OAuth2\Client\Token\AccessToken;
use AdamPaterson\OAuth2\Client\Provider\StripeResourceOwner;

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

/**
* @return StripeResourceOwner
*/
public function fetchUser()
{
return parent::fetchUser();
}
}
Loading