Skip to content

Instantly share code, notes, and snippets.

@JeroenJochems
Created November 28, 2016 13:30
Show Gist options
  • Save JeroenJochems/306e1fa97caa7a6f21817745fda12fec to your computer and use it in GitHub Desktop.
Save JeroenJochems/306e1fa97caa7a6f21817745fda12fec to your computer and use it in GitHub Desktop.
Token en callback
Route::get('/', function () {
$query = http_build_query([
'client_id' => 3,
'redirect_uri' => 'http://testje.dev/callback',
'response_type' => 'code',
'scope' => 'read write'
]);
return redirect('https://nostradamus:t3mp3r@dev2.temper.works/oauth/authorize?'.$query);
});
Route::get('/callback', function (Request $request) {
$http = new GuzzleHttp\Client;
$response = $http->post('https://dev2.temper.works/oauth/token', [
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => '3',
'client_secret' => 'lNy3sOZlU5gwIMpcmDagKLjConQpsezrEDWcabyc',
'redirect_uri' => 'http://testje.dev/callback',
'code' => $request->get("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