1. Go to this page and download the library: Download pltrue/thirdparty_oauth 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/ */
pltrue / thirdparty_oauth example snippets
$api = new SocialiteAuth(config('oauth.github'));
return $api->redirect('github');
public function githubCallBack()
{
$auth = new SocialiteAuth(config('oauth.github'));
$user = $auth->driver('github')->user();
$users = User::query()->where('oauth_id',$user->id)->first();
if(!$users){
$users= User::query()->create([
'name'=> empty($user->name) ?? $user->login,
'email'=>$user->email,
'avatar'=>$user->avatar_url,
'oauth_id'=>$user->id,
'bound_oauth'=>1
]);
}
return $this->respondWithToken($users);
}