PHP code example of mrstebo / laravel-socialite-xero

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


'providers' => [
    // Other service providers

    Mrstebo\LaravelSocialiteXero\Provider::class,

]

'xero' => [
    'client_id' => env('XERO_CLIENT_ID'),
    'client_secret' => env('XERO_CLIENT_SECRET'),
    'redirect' => env('XERO_REDIRECT'),
],



namespace App\Http\Controllers\Auth;

use Socialite;

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

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

        // $user->token;
    }
}

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

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

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