adamwathan / eloquent-oauth

Braindead simple social login with Laravel and Eloquent.
370 stars 44 forks source link

Provider Request: Reddit (code provided) #73

Open oppenheimer opened 9 years ago

oppenheimer commented 9 years ago

It was a step or two above my skill level but I got it working:

https://gist.github.com/619dd0a6536e1333522a.git

adamwathan commented 9 years ago

Hey just wanted to let you know this didn't go unnoticed, but haven't had time yet to give it a full look! It's on my to do list though :) Thanks!

rvanbaalen commented 9 years ago

@adamwathan Your package looks exciting to use but it seems like you haven't had/made much time to maintain it lately.

Would you recommend using your package or is there a better/newer version available? I'd like to extend this package with Trello support.

adamwathan commented 9 years ago

@rvanbaalen I'm still using it myself but haven't had much stuff I've needed to do on it.

All of the providers have been split out into packages like this: https://github.com/adamwathan/socialnorm-facebook

I'd like to honestly collapse them all into one repo but setup a git subtree split deal to break them off into different packages as part of a build process so that it's easy for people to submit new providers to one repo, but just haven't gotten around to it :(

If you'd like to add Trello support, you can actually do it without changing this package. Just create a new provider in your own namespace and register it with the OAuthManager in a service provider and it'll become available :+1:

If you happen to know anything about git subtree or feel like learning (https://makingsoftware.wordpress.com/2013/02/16/using-git-subtrees-for-repository-separation/) I would be happy to collaborate on making it easier to get new providers added to the ecosystem :)

rvanbaalen commented 9 years ago

Thanks for the fast reply! Sorry to hijack this topic though. Probably should start a new issue to discuss this. How exactly do I go about registering my own provider with your OAuthManager? Do you perhaps have an example somewhere?

adamwathan commented 9 years ago

@rvanbaalen it appears not! But it would look something like this if you base your Trello provider on the base OAuth2Provider:

// RobinsAwesomeServiceProvider.php

public function boot()
{
    $this->app['adamwathan.oauth']->registerProvider('trello', $this->app[TrelloProvider::class]);
}

public function register()
{
    $this->app->singleton(TrelloProvider::class, function ($app) {
        $config = $app['config']['eloquent-oauth.providers.trello'];
        $httpClient = new GuzzleHttp\Client;
        $request = new SocialNorm\Request($app['request']->all());
        return new TrelloProvider($config, $httpClient, $request);
    });
}

// TrelloProvider.php

class TrelloProvider extends SocialNorm\Providers\Auth2Provider
{
    // Implement abstract methods and stuff, see any of the other providers for
    // a good starting point.
}
rvanbaalen commented 9 years ago

Great! Thanks Ill keep you updated on the progress.

Trello is a bit funky woth their OAuth implementation so this will be quite the challenge.

By the way, do you use OAuth2 by default? Trello uses OAuth1 I believe.


This email was sent from my iPhone and therefore subject to typos and other inaccuracies.

On 2 okt. 2015, at 14:59, Adam Wathan notifications@github.com wrote:

@rvanbaalen it appears not! But it would look something like this if you base your Trello provider on the base OAuth2Provider:

// RobinsAwesomeServiceProvider.php

public function boot() { $this->app['adamwathan.oauth']->registerProvider('trello', $this->app[TrelloProvider::class]); }

public function register() { $this->app->singleton(TrelloProvider::class, function ($app) { $config = $app['config']['eloquent-oauth.providers.trello']; $httpClient = new GuzzleHttp\Client; $request = new SocialNorm\Request($app['request']->all()); $trelloProvider = new TrelloProvider($config, $httpClient, $request); return }); }

// TrelloProvider.php

class TrelloProvider extends SocialNorm\Providers\Auth2Provider { // Implement abstract methods and stuff, see any of the other providers for // a good strating point } — Reply to this email directly or view it on GitHub.

adamwathan commented 9 years ago

Ah, yeah everything in this package is OAuth 2. I have yet to try to implement an OAuth 1 provider, it might not be possible :(