api authentication
web.php
use Illuminate\Http\Request;
Route::get('/', function () {
$query = http_build_query([
'client_id' => 2,
'redirect_uri' => 'http://offline.xyz.com/callback',
'response_type' => 'code',
'scope' => '',
]);
return redirect ('http://api.xyz.com/oauth/authorize?'.$query);
});
Route::get('/callback', function (Request $request){
$http= new GuzzleHttp\Client;
$response = $http->post('http://api.xyz.com/oauth/token',[
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => 2 ,
'client_secret' => 'tUGYrNeWCGAQt220n88CGoXVu7TRDyZ20fxAlFcL' ,
'redirect_uri' => 'http://offline.xyz.com/callback',
'code' => $request->code,
],
]);
return json_decode((string) $response->getBody(), true);
});
authorize
{"error":"invalid_client","message":"Client authentication failed"}
laravel/passport
api
vue
components as well and there I can see the list of clients I have with their ids. And with that, I am sure I have a client with id = 2.