PHP code example of antwerpes / socialite-doccheck
1. Go to this page and download the library: Download antwerpes/socialite-doccheck 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/ */
antwerpes / socialite-doccheck example snippets
'doccheck' => [
'client_id' => env('DOCCHECK_CLIENT_KEY'),
'client_secret' => env('DOCCHECK_CLIENT_SECRET'),
'redirect' => env('DOCCHECK_REDIRECT_URI'),
'language' => env('DOCCHECK_LANGUAGE', 'de'),
'template' => env('DOCCHECK_TEMPLATE', 'fullscreen_dc'),
'license' => env('DOCCHECK_LICENSE', 'economy'),
],
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Laravel\Socialite\Facades\Socialite;
class LoginController extends Controller
{
public function handleProviderCallback(Request $request)
{
$details = Socialite::driver('doccheck')->user();
$user = User::query()
->firstOrNew([
'id' => $details->getId(),
])
// Only available with the `business` license
->fill([
'email' => $details->getEmail(),
'first_name' => $details->first_name,
'last_name' => $details->last_name,
'title' => $details->title,
'street' => $details->street,
'postal_code' => $details->street,
'city' => $details->city,
'country' => $details->country,
'language' => $details->language,
'gender' => $details->gender,
'profession_id' => $details->profession_id,
'discipline_id' => $details->discipline_id,
]);
$user->save();
auth()->login($user);
return redirect()->intended('/');
}
}
public function showLoginForm(): Response
{
$url = Socialite::driver('doccheck')->redirect()->getTargetUrl();
return response()->view('auth.login', [
'url' => $url,
]);
}
<a href="{{ $url }}">Login with DocCheck</a>
public function showLoginForm(): Response
{
$url = Socialite::driver('doccheck')->redirect()->getTargetUrl();
$state = null;
$query = parse_url($url, PHP_URL_QUERY);
if (is_string($query)) {
parse_str($query, $params);
$state = $params['state'] ?? null;
}
return response()->view('auth.login', [
'url' => $url,
'state' => $state,
]);
}
<script src="[latest main.js]"></script>
<dc-login-button
size="medium"
language="en"
loginClientId="{{ config('services.doccheck.client_id') }}"
redirectUri="{{ config('services.doccheck.redirect') }}"
scope="unique_id profession country language"
state="{{ $state }}"
></dc-login-button>