Skip to content

Instantly share code, notes, and snippets.

@Maras0830
Last active December 23, 2016 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maras0830/031698701c1d975f96c89134bd139959 to your computer and use it in GitHub Desktop.
Save Maras0830/031698701c1d975f96c89134bd139959 to your computer and use it in GitHub Desktop.
Laravel53-passport-client-route
<?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