revolution / socialite-discord
Socialite for Discord
Installs: 3 398
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- ext-json: *
- laravel/socialite: *
Requires (Dev)
- orchestra/testbench: ^9.0
README
https://discordapp.com/developers/docs/topics/oauth2
Requirements
- PHP >= 8.0
No version restrictions. It may stop working in future versions.
Installation
composer require revolution/socialite-discord
config/services.php
'discord' => [ 'client_id' => env('DISCORD_CLIENT_ID'), 'client_secret' => env('DISCORD_CLIENT_SECRET'), 'redirect' => env('DISCORD_REDIRECT'), ],
.env
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
DISCORD_REDIRECT=
Usage
routes/web.php
Route::get('login', [SocialiteController::class, 'login']); Route::get('callback', [SocialiteController::class, 'callback']);
SocialiteController
namespace App\Http\Controllers; use Illuminate\Http\Request; use Laravel\Socialite\Facades\Socialite; class SocialiteController extends Controller { public function login() { return Socialite::driver('discord')->redirect(); } public function callback() { $user = Socialite::driver('discord')->user(); dd($user); } }
Scopes
https://discordapp.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes
public function login() { return Socialite::driver('discord') ->setScopes(['identify', 'email', 'guilds', 'guilds.join']) ->redirect(); }
Demo
https://github.com/kawax/socialite-project
LICENCE
MIT Copyright kawax