sociallogin/sociallogin
Composer 安装命令:
composer require sociallogin/sociallogin
包简介
This will provide social login function
README 文档
README
Laravel sociallogin is a package that simplifies the process of authenticating users with various OAuth providers, such as Google, Facebook. It abstracts away the complexities of OAuth authentication, making it easier to integrate third-party authentication into your Laravel application.
Indexing
LoginIntegration
-
Create a Google Project and Obtain Credentials:
- Go to the Google Developers Console.
- Create a new project and enable the "Google+ API" (or "People API").
- Protect routes and actions based on user roles and permissions.
- Simplified and intuitive API for role and permission management.
- Integration with Laravel's built-in authentication system.
- Under "Credentials," create OAuth 2.0 credentials. Configure the authorized redirect URI for your Laravel app.
-
Create a Facebook App and Obtain Credentials:
- Go to the Facebook Developers Console.
- Create a new app and configure the OAuth settings.
- Note down the App ID and App Secret.
Installation
You can install the package via composer:
composer require sociallogin/sociallogin
ENV
- .env file add this
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT=
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_REDIRECT_URI=
configuration
- In the config/services.php file, add your Google OAuth credentials:
'google' => [ 'client_id' => env('GOOGLE_CLIENT_ID'), 'client_secret' => env('GOOGLE_CLIENT_SECRET'), 'redirect' => env('GOOGLE_REDIRECT'), ], 'facebook' => [ 'client_id' => env('FACEBOOK_CLIENT_ID', 'your_default_client_id'), 'client_secret' => env('FACEBOOK_CLIENT_SECRET', 'your_default_client_secret'), 'redirect' => env('FACEBOOK_REDIRECT_URI'), ],
Publish
- Controller store package controller inside (social/sociallogin/).
php artisan vendor:publish --tag=sociallogin
Routes
- route use in this package
//redirect to google login page
Route::get('auth/google', [Sociallogincontroller::class, "redirectToGoogle"]);
//This is call back function to get google login credential data
Route::get('auth/google/callback', [Sociallogincontroller::class, 'handleGoogleCallback']);
//redirect to facebook login page
Route::get('auth/facebook', [Sociallogincontroller::class, 'redirectToFacebook']);
//This is call back function to get facebook login credential data
Route::get('auth/facebook/callback', [Sociallogincontroller::class, 'handleFacebookCallback']);
Run
-run this command:
php artisan serve
- Hit this url for google login 'http://127.0.0.1:8000/auth/google'
- Hit this url for facebook login 'http://127.0.0.1:8000/auth/facebook'
sociallogin/sociallogin 适用场景与选型建议
sociallogin/sociallogin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 08 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 sociallogin/sociallogin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sociallogin/sociallogin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-03