Is there any change someone has an idea? Every pointer would be very much appreciated. :-)
Testing passport protected API
Dear Laravel Folks
I have just set up a small API that is protected via Passport. So far, everything is working well.
Since I will be the only one consuming the API, I simply use \Laravel\Passport\Http\Middleware\CreateFreshApiToken::class in order to generate and handle my API tokens.
To my question: What is the best way to handle tokens in my application tests? actingAs($user) does not seem to magically add the user's token to the request. I can use $this->withoutMiddleware();, but that feels kind of dirty.
Any ideas or best practices?
Thank you very much for you help!
This turned out to be much easier than expected, and was even covered in the documentation. A simple $this->actingAs($user, 'api') does the trick!
Please or to participate in this conversation.