I'm trying to create a bearer token for passport so I can use my api routes internally. I send a post request to /oauth/token with the client id and client secret. The code that generates the bearer token looks like this.
public function generateToken() {
try {
$req = Request::create('/oauth/token', 'POST', [
'grant_type' => 'client_credentials',
'client_id' => '1',
'client_secret' => 'POe81tKvmZ0DhBdtwdM7VPoV5tTKobVYzSc9A0RX',
'scope' => '*',
]);
$res = app()->handle($req);
return $res;
} catch (Exception $e){
log::critical('Failed to generate bearer token.');
} catch (error $e) {
log::critical('Failed to generate bearer token.');
}
}
However when trying to do this request I get a 401 authorised.
#content: "{"error":"invalid_client","message":"Client authentication failed"}" #version: "1.1"#statusCode: 401 #statusText: "Unauthorized"
Is there anyway of fixing this?