socialiteproviders/manager
Composer 安装命令:
composer require socialiteproviders/manager
包简介
Easily add new or override built-in providers in Laravel Socialite.
README 文档
README
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 totrueorfalse- You can override a config dynamically
- It retrieves environment variables directly from the
.envfile instead of also having to configure the services array.
Available Providers
- See the SocialiteProviders list
- You can also make your own or modify someone else's
Reference
- Laravel docs about events
- Laracasts video on events in Laravel 5
- Laravel Socialite Docs
- Laracasts Socialite video
Creating a Handler
Below is an example handler. You need to add this full class name to the listen[] in the EventServiceProvider.
- See also the Laravel docs about events.
providernameis the name of the provider such asmeetup.- You will need to change your the namespacing and class names of course.
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
- Look at the already created providers for inspiration.
- See this article on Medium
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
socialiteproviders/manager 适用场景与选型建议
socialiteproviders/manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46.92M 次下载、GitHub Stars 达 426, 最近一次更新时间为 2015 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「oauth」 「manager」 「laravel」 「providers」 「socialite」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 socialiteproviders/manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 socialiteproviders/manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 socialiteproviders/manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
WeChat OAuth SDK
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Ory-Hydra OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Library for ORCID web services
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
KCFinder web file manager
统计信息
- 总下载量: 46.92M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 431
- 点击次数: 17
- 依赖项目数: 622
- 推荐数: 2
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-19