PHPackages                             a2workspace/laravel-social-entry - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. a2workspace/laravel-social-entry

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

a2workspace/laravel-social-entry
================================

提供一個整合的第三方登入入口

1.0.0(3y ago)563[1 issues](https://github.com/A2Workspace/laravel-social-entry/issues)MITPHPPHP ^7.4|^8.0

Since Jul 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/A2Workspace/laravel-social-entry)[ Packagist](https://packagist.org/packages/a2workspace/laravel-social-entry)[ RSS](/packages/a2workspace-laravel-social-entry/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

Laravel-Social-Entry
====================

[](#laravel-social-entry)

[ ![](https://github.com/A2Workspace/laravel-social-entry/actions/workflows/coverage.yml/badge.svg)](https://github.com/A2Workspace/laravel-social-entry)[ ![](https://camo.githubusercontent.com/ddc0099cf4d0d9a3e0d3477c4680685f022e7259ead40cede52eb66661154456/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f4132576f726b73706163652f6c61726176656c2d736f6369616c2d656e7472792f74657374733f7374796c653d666c61742d737175617265)](https://github.com/A2Workspace/laravel-social-entry)[ ![](https://camo.githubusercontent.com/83c17c94cbf57174909f26bc3a25529baa235d92356edd69d9380e9f9023300a/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f4132576f726b73706163652f6c61726176656c2d736f6369616c2d656e7472792e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/A2Workspace/laravel-social-entry)[ ![](https://camo.githubusercontent.com/6411a36a62c3c3dcd34e3010c05a9f63c5452b0fbd8f3266ee6d1a4a6774be6f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4132576f726b73706163652f6c61726176656c2d736f6369616c2d656e7472793f7374796c653d666c61742d737175617265)](https://github.com/A2Workspace/laravel-social-entry/blob/master/LICENSE)[ ![](https://camo.githubusercontent.com/351ae9902310060d18b94e5061bdd1e5aa4380931d89c77698019214097c0c28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6132776f726b73706163652f6c61726176656c2d736f6369616c2d656e7472792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/a2workspace/laravel-social-entry)[ ![](https://camo.githubusercontent.com/2ba45bc6852b1e0e1ec4976888aea14af667c306860cf32886e7f4e0e4a43481/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6132776f726b73706163652f6c61726176656c2d736f6369616c2d656e7472792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/a2workspace/laravel-social-entry)

提供一個幾乎零配置，整合前後端的第三方登入的 API 身分認證接口

特性:

- 基於 [Laravel Socialite](https://github.com/laravel/socialite) 的 API 身分認證接口
- 專為前端 API 接口設計
- 解決一般登入與社群登入不統一的問題
- 解決新使用者透過社群登入後，要填寫完成註冊表格才能完成註冊的情況
- 整合社群帳號連結功能
- 支援多使用者模型
- 相容 **Nuxt.js**；參考套件 [nuxt-social-entry](https://github.com/A2Workspace/nuxt-social-entry)

快速前往:

- [Installation | 安裝](#Installation--%E5%AE%89%E8%A3%9D)
- [Configuration | 配置](#Configuration--%E9%85%8D%E7%BD%AE)
    - [一個簡單的設定範例](#%E4%B8%80%E5%80%8B%E7%B0%A1%E5%96%AE%E7%9A%84%E8%A8%AD%E5%AE%9A%E7%AF%84%E4%BE%8B)
    - [Registering Routes | 註冊路由](#Registering-Routes--%E8%A8%BB%E5%86%8A%E8%B7%AF%E7%94%B1)

---

Installation | 安裝
-----------------

[](#installation--安裝)

要在專案中使用 SocialEntry，執行下列命令透過 Composer 引入到你的 Laravel 專案中:

```
composer require a2workspace/laravel-social-entry
```

接著使用 `vendor:publish` 命令生成設定檔:

```
php artisan vendor:publish --tag=@a2workspace/laravel-social-entry
```

現在你可以在 `config/social-entry.php` 中指定要啟用的第三方授權登入。

Configuration | 配置
------------------

[](#configuration--配置)

開始用 SocialEntry 前，如同使用 [Laravel Socialite](https://laravel.com/docs/9.x/socialite)，你必須要先將第三方服務設定加到 `config/services.php` 內。你可以使用下面的範例或參考說明 [Laravel Socialite Configuration](https://laravel.com/docs/9.x/socialite#configuration)。

### 一個簡單的設定範例:

[](#一個簡單的設定範例)

```
'github' => [
    'client_id' => env('GITHUB_CLIENT_ID'),
    'client_secret' => env('GITHUB_CLIENT_SECRET'),
    'redirect' => env('GITHUB_REDIRECT_URL', '/auth/github/callback'),
],

'facebook' => [
    'client_id' => env('FACEBOOK_CLIENT_ID'),
    'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
    'redirect' => env('FACEBOOK_REDIRECT_URL', '/auth/facebook/callback'),
],

'google' => [
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => env('GOOGLE_REDIRECT_URL', '/auth/google/callback'),
],

'line' => [
    'client_id' => env('LINE_CHANNEL_ID'),
    'client_secret' => env('LINE_SECRET'),
    'redirect' => env('LINE_REDIRECT_URL', '/auth/line/callback'),
],
```

`.env`/`.env.example` 設定:

```
# See https://github.com/settings/developers
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_REDIRECT_URL=

# See https://developers.facebook.com/apps/?show_reminder=true
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_REDIRECT_URL=

# See https://console.cloud.google.com/apis/credentials
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URL=

# See https://developers.line.biz/console/
LINE_CHANNEL_ID=
LINE_SECRET=
LINE_REDIRECT_URL=
```

這裡提供第三方的登入設定頁面連結:

- `Github`:
- `Facebook`: [https://developers.facebook.com/apps/?show\_reminder=true](https://developers.facebook.com/apps/?show_reminder=true)
- `Google`:
- `Line`:

### Registering Routes | 註冊路由

[](#registering-routes--註冊路由)

接著你應該在 `App\Providers\AuthServiceProvider` 的 `boot` 方法中，呼叫 `SocialEntry::routes` 方法來註冊路由。

```
