Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

API Resource

Hello,

I have tried to securize an API with Passport with this tutorial.

I have created an API Resource like in this tutorial :

https://www.twilio.com/blog/build-secure-api-php-laravel-passport

When I register a new account, the application does not returns the token, but it returns an HTML page.

Here is the code for my resource.

public function toArray($request)
{
    return parent::toArray($request);
}

And here is the return code of my controller.

return response([
    'ceo' => new CEOResource($ceos),
    'message' => 'Created successfully'
], 200);

I wonder why it returns me an HTML page instead of an array.

Do you have any idea ?

Thank you for your answer.

Vincent

0 likes
2 replies
vincent15000's avatar

I have noticed that something's wrong in my post : the return response in my CEO controller has nothing to do with my problem, that's something else I haven't tested yet.

Here is the return code of the register function in the AuthController.

return response([
    'user' => $user,
    'access_token' => $accessToken
]);

vincent15000's avatar
vincent15000
OP
Best Answer
Level 63

I have found the problem.

It wasn't a Laravel problem, but a Postman problem.

Sorry ;).

Please or to participate in this conversation.