Last active
December 23, 2016 08:31
-
-
Save Maras0830/031698701c1d975f96c89134bd139959 to your computer and use it in GitHub Desktop.
Laravel53-passport-client-route
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
|-------------------------------------------------------------------------- | |
| Web Routes | |
|-------------------------------------------------------------------------- | |
| | |
| Here is where you can register web routes for your application. These | |
| routes are loaded by the RouteServiceProvider within a group which | |
| contains the "web" middleware group. Now create something great! | |
| | |
*/ | |
use Illuminate\Http\Request; | |
Route::get('/', function () { | |
return view('welcome'); | |
}); | |
Route::get('/redirect', function () { | |
$query = http_build_query([ | |
'client_id' => '5', | |
'redirect_uri' => 'http://Laravel53-passport-client.dev/callback', | |
'response_type' => 'code', | |
'scope' => '', | |
]); | |
return redirect('http://Laravel53-passport-server.dev/oauth/authorize?'.$query); | |
}); | |
Route::get('/callback', function (Request $request) { | |
$http = new GuzzleHttp\Client; | |
$response = $http->post('http://Laravel53-passport-server.dev/oauth/token', [ | |
'form_params' => [ | |
'grant_type' => 'authorization_code', | |
'client_id' => '5', | |
'client_secret' => 'esRSCGGNtJHhPt2huGM4grC24WDcmU82C3SwKGUE', | |
'redirect_uri' => 'http://Laravel53-passport-client.dev/callback', | |
'code' => $request->code, | |
], | |
]); | |
return json_decode((string) $response->getBody(), true); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment