commerceguys / guzzle-oauth2-plugin Goto Github PK
View Code? Open in Web Editor NEWProvides an OAuth2 plugin (subscriber) for Guzzle
License: MIT License
Provides an OAuth2 plugin (subscriber) for Guzzle
License: MIT License
I’ve opened a PR at the Guzzle 4 repo for an OAuth2 subscriber. As I took some ideas from your plugin, it would be useful if you guys had a look. If you want to be listed in the credits, please let me know.
Hi Guys,
I am using the PasswordCredentials grant type and I think I noticed a problem.
On line 19 of the PasswordCredentials GrantType it merges the parents required parameters with the username,password.
The parents getRequired returns 'client_id'.
This means that the PasswordCredentials required parameters become ['client_id', 'username', 'password']. I don't however think this is correct as looking at the RFC it states that only grant_type, username and password are the required parameters.
I have only started using the plugin so I might be doing things wrong but I wanted to flag it anyway.
Thanks,
Stephen
Could you please change composer to use version 3.0?
Please have a look at PR #23
Hi!
Do you already have some migrations plans for the getConfig method which will be removed in Guzzle 8?
It's already marked as deprecated and as far as I have followed the messages from the guzzle team there won't be an alternative to access the "real" config of the client..
Thanks &
Regards Alex
is it possible to login with login form? for example login with "https://github.com/login" form?
Add implicit grant type
Hi,
While doing some test whit AutorizationCode, I've notice that the "redirect_uri" is missing, so I added it in AuthorizationCode.php, as follows:
class AuthorizationCode implements GrantTypeInterface
{
/** @var ClientInterface The token endpoint client */
protected $client;
/** @var Collection Configuration settings */
protected $config;
public function __construct(ClientInterface $client, $config)
{
$this->client = $client;
$this->config = Collection::fromConfig($config, array(
'client_secret' => '',
'scope' => '',
'redirect_uri' => '',
), array(
'client_id', 'code', 'redirect_uri'
));
}
/**
* {@inheritdoc}
*/
public function getTokenData()
{
$postBody = array(
'grant_type' => 'authorization_code',
'code' => $this->config['code'],
'redirect_uri' => $this->config['redirect_uri'],
);
if ($this->config['scope']) {
$postBody['scope'] = $this->config['scope'];
}
$request = $this->client->post(null, array(), $postBody);
$request->setAuth($this->config['client_id'], $this->config['client_secret']);
$response = $request->send();
$data = $response->json();
$requiredData = array_flip(array('access_token', 'expires_in', 'refresh_token'));
return array_intersect_key($data, $requiredData);
}
}
I'm trying to use the AuthorizationCode flow, but I can't figure out how. Could you improve the documentation by explain this flow as well?
Thank you
Trying to use this plugin. My composer.json file is:
{
"require": {
"commerceguys/guzzle-oauth2-plugin": "~2.0"
}
}
when I do a "drush composer install" I get the error:
[RuntimeException]
Could not load package commerceguys/guzzle-oauth2-plugin in http://packagist.org: [UnexpectedValueException] Could not parse version constraint ^2.0: Invalid version string "^2.0"
My composer version is:
Composer version 1.0-dev (b2173d28fc8b56236eddc8aa10dcda61471633ec) 2015-06-16 10:43:55
The issue seems to be that guzzle-oauth2-plugin has a dependency:
"firebase/php-jwt": "^2.0"
and it doesn't seem to like the ^ character. Any ideas?
Please make this library compatible with Guzzle version 6
Hi CommerceGuys,
I've forked your excellent work to add Cache integration ( Doctrine cache ) .
It add a dependency on doctrine/cache in composer but doesn't introduce any bc break.
Is it something that your interested in, if yes i can send a PR.
Regards
Xavier
Hi guys, is there a way to cache the access token, so that It does not need to get it on every request?
Hi,
When I try using the example on the front page I am getting the following error:
Config is missing the following keys: refresh_token
Hi, I'm trying to run your plugin but an error stops me. Please help ;)
My code is:
$url = 'http://httpbin.org/get';
$oauth2Client = new Client(['base_url' => $url]);
$config = array(
'username' => 'myusername',
'password' => 'mypassword',
'client_id' => 'myclient',
'client_secret' => 'mysecret',
'scope' => 'administration', // Optional.
);
$grantType = new PasswordCredentials($oauth2Client, $config);
ERROR:
Catchable Fatal Error: Argument 1 passed to CommerceGuys\Guzzle\Plugin\Oauth2\GrantType\PasswordCredentials::__construct() must be an instance of Guzzle\Http\ClientInterface, instance of GuzzleHttp\Client given
composer.json requires:
"guzzlehttp/guzzle": "*",
"guzzlehttp/oauth-subscriber": "dev-master",
"commerceguys/guzzle-oauth2-plugin": "dev-master"
FYI:
firebase/php-jwt dependency is updated to version 2.2.0.
After a composer update deserialization no longer works, if I lock the firebase/php-jwt dependency to 2.1.0 all works as expected.
I will try to look for the issue myself.
Hi,
Just want to find out which method would call /oauth/v2/token
to get access_token
? The reason I'm asking because I want to avoid calling /oauth/v2/token
per request otherwise application would be slow. My plan is to keep it in cache (memcached) for about 3000sec.
Thanks
class Testing
{
private function getToken(Client $client)
{
// ....
$token = $this->getToken($client);
$subscriber = $this->getSubscriber($token);
// ....
}
private function getToken(Client $client)
{
$config = [
'client_id' => '123456',
'client_secret' => '12345qwerasdf',
'token_url' => '/oauth/v2/token'
];
return new ClientCredentials($client, $config);
}
private function getSubscriber($token)
{
return new Oauth2Subscriber($token);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.