atari/passport-social-grant
最新稳定版本:v4.2.0
Composer 安装命令:
composer require atari/passport-social-grant
包简介
Social grant for Laravel Passport
README 文档
README
This package adds a social grant to your Oauth2 Server.
Installation
You can install the package via composer:
composer require adaojunior/passport-social-grant
The package will automatically register its service provider. Or you may manually add the service provider in your config/app.php file:
'providers' => [ // ... Adaojunior\PassportSocialGrant\SocialGrantServiceProvider::class, ];
Setup
- Implement the
SocialGrantUserProviderinterface:
<?php namespace App\SocialGrant; use Laravel\Socialite\Facades\Socialite; use Illuminate\Contracts\Auth\Authenticatable; use League\OAuth2\Server\Entities\ClientEntityInterface; use Adaojunior\PassportSocialGrant\SocialGrantUserProvider; class UserProvider implements SocialGrantUserProvider { /** * Retrieve a user by provider and access token. * * @param string $provider * @param string $accessToken * @param ClientEntityInterface $client * @return Authenticatable|null */ public function getUserByAccessToken(string $provider, string $accessToken, ClientEntityInterface $client):? Authenticatable { } }
- Bind
SocialGrantUserProviderinterface to your implementation in theregistermethod of your application service providerapp/Providers/AppServiceProvider.php:
$this->app->bind( Adaojunior\PassportSocialGrant\SocialGrantUserProvider::class, App\SocialGrant\UserProvider::class );
Usage
$response = $http->post('http://your.app/oauth/token', [ 'form_params' => [ 'grant_type' => 'social', 'client_id' => $clientId, 'client_secret' => $clientSecret, 'provider' => $providerName, // name of provider (e.g., 'facebook', 'google' etc.) 'access_token' => $providerAccessToken, // access token issued by specified provider ], ]);
统计信息
- 总下载量: 57.5k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-16