1 Star 0 Fork 0

Yeardley / Manager

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Socialite Providers Manager

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Total Downloads Latest Unstable Version License Stories in Ready SensioLabsInsight

About

A package for Laravel Socialite that allows you to easily add new providers or override current providers.

Benefits

  • You will have access to all of the providers that you load in using the manager.
  • Instantiation is deferred until Socialite is called
  • You can override current providers
  • You can create new providers
  • Lumen usage is easy
  • stateless() can be set to true or false
  • You can override a config dynamically
  • It retrieves environment variables directly from the .env file instead of also having to configure the services array.

Available Providers

Reference

Creating a Handler

Below is an example handler. You need to add this full class name to the listen[] in the EventServiceProvider.

namespace Your\Name\Space;

use SocialiteProviders\Manager\SocialiteWasCalled;

class ProviderNameExtendSocialite
{
    public function handle(SocialiteWasCalled $socialiteWasCalled)
    {
        $socialiteWasCalled->extendSocialite('providername', \Your\Name\Space\Provider::class);
    }
}

Creating a Provider

Overriding a Built-in Provider

You can easily override a built-in laravel/socialite provider by creating a new one with exactly the same name (i.e. 'facebook').

Dynamically Passing a Config

You can dynamically pass a config by using:

$clientId = "secret";
$clientSecret = "secret";
$redirectUrl = "http://yourdomain.com/api/redirect";
$additionalProviderConfig = ['site' => 'meta.stackoverflow.com'];
$config = new \SocialiteProviders\Manager\Config($clientId, $clientSecret, $redirectUrl, $additionalProviderConfig);
return Socialite::with('provider-name')->setConfig($config)->redirect();

You must call this before you run any Socialite methods.

Creating an OAuth1 Server Class

Take a look at the other OAuth1 providers for inspiration.

Getting the Access Token Response Body

Laravel Socialite by default only allows access to the access_token. Which can be accessed via the \Laravel\Socialite\User->token public property. Sometimes you need access to the whole response body which may contain items such as a refresh_token.

To make this possible, the OAuth2 provider class needs to extend \SocialiteProviders\Manager\OAuth2\AbstractProvider and OAuth1 providers need to utilize the \SocialiteProviders\Manager\OAuth1\AbstractProvider and \SocialiteProviders\Manager\OAuth1\Server.

You can access it from the user object like so: $user->accessTokenResponseBody

The MIT License (MIT) Copyright (c) 2015 Andy Wendt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Easily add new or override built-in Laravel Socialite providers 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/yeardley/Manager.git
git@gitee.com:yeardley/Manager.git
yeardley
Manager
Manager
master

搜索帮助