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

Introducing a wrapper to the Guzzle oAuth plugin #143

Closed
wants to merge 1 commit into from
Closed

Introducing a wrapper to the Guzzle oAuth plugin #143

wants to merge 1 commit into from

Conversation

rtuin
Copy link

@rtuin rtuin commented Jan 28, 2013

I was toying around with the React HttpClient, and found that it lacked the support for oAuth.

I would like to hear your thoughts and feedback on this.

Some example code:

<?php

require_once 'vendor/autoload.php';

$loop = React\EventLoop\Factory::create();

$resolverFactory = new React\Dns\Resolver\Factory();
$httpClientFactory = new React\HttpClient\Factory();

$dnsResolver = $resolverFactory->createCached('8.8.8.8', $loop);
$client = $httpClientFactory->create($loop, $dnsResolver);

$oauth = new React\HttpClient\Authentication\Oauth(array(
    'consumer_key' => '...',
    'consumer_secret' => '...',
    'token' => '...',
    'token_secret' => '...'
));

$request = $client->request('GET', 'https://stream.twitter.com/1.1/statuses/sample.json');
$request->on('response', function($response) {
    $response->on('data', function($data) {
        echo $data;
    });
});
$request->on('writing-headers', array($oauth, 'onWritingHeaders'));
$request->end();
$loop->run();

@rtuin
Copy link
Author

rtuin commented Jan 28, 2013

I have to add; i am not really sure how to test this. Suggestions?

@igorw
Copy link
Contributor

igorw commented Jan 28, 2013

Looks nice! As per IRC, this is kind of a fundamental decision.

Either:

  • We start exposing more parts of guzzle and allow using plugins directly. In that case we need to be careful not to get any blocking calls.
  • We remove guzzle (see also [0.3] Replace guzzle/http with custom implementation #131) and do specific integrations like oauth to other third party libs. Requires more bindings to glue things together, but overall less dependencies.

I'm not yet sure what the best approach is.

@igorw
Copy link
Contributor

igorw commented Jan 30, 2013

I've discussed this with @cboden and @mtdowling. We all agree that guzzle/http is a bad fit, and that the risk of guzzle plugins containing blocking calls is not really worth it.

As such, I'm going to close this PR. If you want to re-work an alternate oauth solution on top of #131, that would be awesome. Just ping me in #reactphp if you have any questions -- sorry :).

@igorw igorw closed this Jan 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants