1<?php
2
3namespace App\Http\Controllers\Auth;
4
5use App\Http\Controllers\Controller;
6use Laravel\Socialite\Facades\Socialite;
7
8class LoginController extends Controller
9{
10 /**
11 * Redirect the user to the GitHub authentication page.
12 *
13 * @return \Illuminate\Http\Response
14 */
15 public function redirectToProvider()
16 {
17 return Socialite::driver('github')->redirect();
18 }
19
20 /**
21 * Obtain the user information from GitHub.
22 *
23 * @return \Illuminate\Http\Response
24 */
25 public function handleProviderCallback()
26 {
27 $user = Socialite::driver('github')->user();
28
29 // $user->token;
30 }
31}
1return Socialite::driver('google')
2 ->with(['hd' => 'example.com'])
3 ->redirect();
1$user = Socialite::driver('twitter')->userFromTokenAndSecret($token, $secret);
1$user = Socialite::driver('github')->user();
2
3// OAuth Two Providers
4$token = $user->token;
5$refreshToken = $user->refreshToken; // not always provided
6$expiresIn = $user->expiresIn;
7
8// OAuth One Providers
9$token = $user->token;
10$tokenSecret = $user->tokenSecret;
11
12// All Providers
13$user->getId();
14$user->getNickname();
15$user->getName();
16$user->getEmail();
17$user->getAvatar();
1return Socialite::driver('github')
2 ->scopes(['read:user', 'public_repo'])
3 ->redirect();
1Route::get('login/github', 'Auth\LoginController@redirectToProvider');
2Route::get('login/github/callback', 'Auth\LoginController@handleProviderCallback');