Documentation Index
Fetch the complete documentation index at: https://kawax.biz/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This package provides a LINE Login driver using the standard Socialite::extend() approach. It works with the same API as any built-in Socialite provider.
Available drivers:
| Driver | Description |
|---|
line-login | OAuth2 authentication via LINE Login |
Configuration
.env
LINE_LOGIN_CLIENT_ID=
LINE_LOGIN_CLIENT_SECRET=
LINE_LOGIN_REDIRECT=
Basic usage
Define routes
Add redirect and callback routes to routes/web.php.use App\Http\Controllers\SocialiteController;
Route::get('login', [SocialiteController::class, 'login']);
Route::get('callback', [SocialiteController::class, 'callback']);
Create a controller
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use Laravel\Socialite\Facades\Socialite;
class SocialiteController extends Controller
{
public function login()
{
return Socialite::driver('line-login')->redirect();
}
public function callback(Request $request)
{
if ($request->missing('code')) {
return redirect('/login')->withErrors('Authentication was cancelled.');
}
/** @var \Laravel\Socialite\Two\User */
$user = Socialite::driver('line-login')->user();
$loginUser = User::updateOrCreate([
'line_id' => $user->id,
], [
'name' => $user->nickname,
'avatar' => $user->avatar,
'access_token' => $user->token,
'refresh_token' => $user->refreshToken,
]);
auth()->login($loginUser, true);
return redirect()->route('home');
}
}
Optional parameters
Pass additional parameters with with().
public function login()
{
return Socialite::driver('line-login')->with([
'prompt' => 'consent',
'bot_prompt' => 'normal',
])->redirect();
}
Scopes
Specify the permissions you want with scopes.
public function login()
{
return Socialite::driver('line-login')
->setScopes(['profile', 'openid'])
->redirect();
}
See LINE Login scopes for the full list.