Last active
April 11, 2019 11:08
-
-
Save orobogenius/db52f0c736c26942ffeab87c8519df6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Laravel\Passport\Passport; | |
use App\OAuth\SocialUserProvider; | |
use App\OAuth\Bridge\Grant\SocialGrant; | |
use Illuminate\Support\ServiceProvider; | |
use App\OAuth\SocialUserProviderInterface; | |
use League\OAuth2\Server\AuthorizationServer; | |
use App\OAuth\Bridge\Repositories\ScopeRepository; | |
use Laravel\Passport\Bridge\RefreshTokenRepository; | |
class OAuthServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Register any application services. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
$this->app->extend(AuthorizationServer::class, function ($server, $app) { | |
return tap($server, function ($server) { | |
$server->enableGrantType( | |
$grantType = $this->makeSocialGrant(), Passport::tokensExpireIn() | |
); | |
}); | |
}); | |
// Bind the SocialUserProviderInterface to its implementation | |
$this->app->singleton(SocialUserProviderInterface::class, SocialUserProvider::class); | |
} | |
/** | |
* Create and configure an instance of Social Grant. | |
* | |
* @return \App\OAuth\Bridge\Grant\SocialGrant | |
*/ | |
protected function makeSocialGrant() | |
{ | |
$grant = new SocialGrant( | |
$this->app->make(SocialUserProviderInterface::class), | |
$this->app->make(RefreshTokenRepository::class) | |
); | |
$grant->setRefreshTokenTTL(Passport::refreshTokensExpireIn()); | |
return $grant; | |
} | |
/** | |
* Bootstrap any application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment