atari/passport-social-grant 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Implement the SocialGrantUserProvider interface:
<?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
    {

    }
}
  1. Bind SocialGrantUserProvider interface to your implementation in the register method of your application service provider app/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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 30
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-16