sociallogin/sociallogin 问题修复 & 功能扩展

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

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

sociallogin/sociallogin

Composer 安装命令:

composer require sociallogin/sociallogin

包简介

This will provide social login function

README 文档

README

Latest Version on Packagist Total Downloads License

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

  1. Login Integration
  2. Installation
  3. ENV
  4. configuration
  5. Publish
  6. Routes
  7. Run

LoginIntegration

  1. 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.
  2. 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 

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-03