PHP code example of pirabyte / lexwareoffice-socialite

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

    

pirabyte / lexwareoffice-socialite example snippets


'lexwareoffice' => [
    'url' => env('LEXWARE_OFFICE_URL', 'https://sandbox.example.com'),
    'api' => env('LEXWARE_OFFICE_API', 'https://api.sandbox.example.com'),
    'client_id' => env('LEXWARE_OFFICE_CLIENT_ID'),
    'client_secret' => env('LEXWARE_OFFICE_CLIENT_SECRET'),
    'redirect' => env('LEXWARE_OFFICE_REDIRECT_URL'),
],

Event::listen(function (SocialiteWasCalled $event) {
    $event->extendSocialite('lexwareoffice', \Pirabyte\Socialite\LexwareOffice\Provider::class);
});

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

public function callback(): \Illuminate\Http\RedirectResponse
{
    $connection = Socialite::driver('lexwareoffice')->user();
    $user = request()->user();

    LexwareOfficeClient::updateOrCreate([
        'user_id' => $user->id,
    ], [
        'access_token' => $connection->token,
        'refresh_token' => $connection->refreshToken,
        'expires_at' => Carbon::now()->addSeconds($connection->expiresIn),
    ]);

    return redirect()->route('dashboard');
}