PHP code example of kayckmatias / discord-socialite-provider

1. Go to this page and download the library: Download kayckmatias/discord-socialite-provider library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kayckmatias / discord-socialite-provider example snippets


   'providers' => [
        KayckMatias\Laravel\Socialite\DiscordServiceProvider::class,
    ],
   

    'discord' => [
        'client_id' => env('DISCORD_CLIENT_ID'),
        'client_secret' => env('DISCORD_CLIENT_SECRET'),
        'redirect' => '/auth/discord/callback',
    ]
    

use Laravel\Socialite\Facades\Socialite;

public function redirectToDiscord()
{
    return Socialite::driver('discord')->redirect();
}

use Laravel\Socialite\Facades\Socialite;

public function handleDiscordCallback()
{
    $user = Socialite::driver('discord')->user();

    // Access user details
    $id = $user->getId();
    $name = $user->getName();
    $nickname = $user->getNickname();
    $email = $user->getEmail();
    $avatar = $user->getAvatar();

    // Handle the user data
}

return Socialite::driver('discord')
    ->setScopes(['identify', 'email', 'bot'])
    ->redirect();

return Socialite::driver('discord')
    ->withPermissions('1689934340028480')
    ->redirect();

return Socialite::driver('discord')
    ->asBot()
    ->redirect();

return Socialite::driver('discord')
    ->withGuildId('0000000000000000000')
    ->redirect();

return Socialite::driver('discord')
    ->withConsent()
    ->redirect();