PHP code example of katsana / socialite

1. Go to this page and download the library: Download katsana/socialite 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/ */

    

katsana / socialite example snippets


'providers' => [

    // Other service providers...
    Katsana\ServiceProvider::class,
    Laravel\Socialite\SocialiteServiceProvider::class,
    SocialiteProviders\Manager\ServiceProvider::class,

],

'Katsana' => Katsana\Katsana::class,
'Socialite' => Laravel\Socialite\Facades\Socialite::class,

'katsana' => [
    'environment' => 'production',
    'client_id' => 'your-katsana-client-id',
    'client_secret' => 'your-katsana-client-secret',
    'redirect' => 'http://your-callback-url',
    //Optional
    'endpoints'=>[
        'api' => 'http://katsana-api-endpoint',
        'oauth' => 'http://katsana-outh-endpoint',
    ],
    '

    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        // Other events...
        \SocialiteProviders\Manager\SocialiteWasCalled::class => [
            \Katsana\Socialite\Bootstrap::class,
        ],
    ];



namespace App\Http\Controllers\Auth;

use Laravel\Socialite\Facades\Socialite;

class PassportController extends Controller
{
    /**
     * Redirect the user to the KATSANA authentication page.
     *
     * @return Response
     */
    public function redirectToProvider()
    {
        return Socialite::driver('katsana')->redirect();
    }

    /**
     * Obtain the user information from KATSANA.
     *
     * @return Response
     */
    public function handleProviderCallback()
    {
        $passport = Socialite::driver('katsana')->user();

        // $passport->token;
    }
}

return Socialite::driver('katsana')
            ->scopes(['scope1', 'scope2'])->redirect();

Route::get('passport', 'Auth\PassportController@redirectToProvider');
Route::get('passport/callback', 'Auth\PassportController@handleProviderCallback');

return Socialite::driver('katsana')
            ->with(['hd' => 'example.com'])->redirect();

return Socialite::driver('katsana')->stateless()->user();

$passport = Socialite::driver('katsana')->user();

// OAuth Two Providers
$token = $passport->token;
$refreshToken = $passport->refreshToken; // not always provided
$expiresIn = $passport->expiresIn;

// Helper methods.
$passport->getId();
$passport->getName();
$passport->getEmail();
$passport->getAvatar();
$passport->getRaw();

$passport = Socialite::driver('katsana')->userFromToken($token);