PHP code example of mrstebo / laravel-socialite-ekm

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

    

mrstebo / laravel-socialite-ekm example snippets


'providers' => [
    // Other service providers
    
    Mrstebo\LaravelSocialiteEkm\Provider::class,

]

'ekm' => [
    'client_id' => env('EKM_CLIENT_ID'),
    'client_secret' => env('EKM_CLIENT_SECRET'),
    'redirect' => env('EKM_REDIRECT'),
],



namespace App\Http\Controllers\Auth;

use Socialite;

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

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

        // $user->token;
    }
}

Route::get('auth/ekm', 'Auth\AuthController@redirectToProvider');
Route::get('auth/ekm/callback', 'Auth\AuthController@handleProviderCallback');

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

// OAuth Two Providers
$token = $user->token;
$refreshToken = $user->refreshToken; // may not always be provided
$expiresIn = $user->expiresIn;

// EKM Specific Providers
$username = $user->user['sub'];
$serverId = $user->user['server_id'];