REST V8 API access_token return "No user found"

I have setup V8 API and try to get access token as follow:

$ch = curl_init();
$header = array(
    'Content-type: application/vnd.api+json',
    'Accept: application/vnd.api+json',
);
$postStr = json_encode(array(
    'grant_type' => 'password',
    'client_id' => '84d826ed-dd85-7120-c419-5df4fd0cdaac',
    'client_secret' => 'test2',
    'username' => 'max',
    'password' => 'max',
));
$url = 'https://crm.example.com/Api/access_token';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$output = curl_exec($ch);

var_dump($output);

It return

"{"error":"unknown_error","message":"No user found"}"

The message is apprently from AccessTokenRepository.php file line 74, there is $_POST['username'], which cannot be set by JSON payload.

What is the correct way to get access token?

2 Likes

Same here. Tried to Login with the ‘grant_type’ ‘password’, but the above metioned error persists in 7.10.22.

Thank you