Required option "access_token" not passed - Laravel 10
Hey there 👋
This is quite interesting! I will spin up a new Laravel app now and try to reproduce this as well!
Hey!
Did you follow a specific tutorial?
I think that you have to convert the Converting Authorization Codes To Access Tokens in order for this to work as described here:
This /oauth/token route will return a JSON response containing access_token
, refresh_token
, and expires_in
attributes.
You can use then the access_token for the authentication.
Or you can request a new token with:
use Illuminate\Support\Facades\Http;
$response = Http::asForm()->post('http://passport-app.test/oauth/token', [
'grant_type' => 'password',
'client_id' => 'client-id',
'client_secret' => 'client-secret',
'username' => '[email protected]',
'password' => 'my-password',
'scope' => '',
]);
return $response->json();
Let me know how it goes!
This is very interesting! If you were to do php artisan route:list | grep 'token'
do you see the correct controller handling the requests for that endpoint?
It should look like this:
POST oauth/token ................................. passport.token › Laravel\Passport › AccessTokenController@issueToken
I just tested this out with a fresh new Laravel 10 App deployed with the 1-Click image on DigitalOcean:
And it seems to be working as expected.
Did you follow a specific article for the setup? Or did you just follow the documentation?
If you followed an article, can you share the link here so I can test it out as well?
Sure, yeah. I followed the article below: https://www.toptal.com/laravel/passport-tutorial-auth-user-access
I'll admit it's outdated, however I also used the 10.x docs. This means there is no Passport::routes. aliases and providers are set correctly in app/config.php.
Hi there,
Indeed, it looks outdated as it is referring to Laravel 7 and also the laravel/ui
package.
Are you using the laravel/ui
package as well?
Have you tried following the steps form the Laravel docs on a fresh new install?
Can you share the exact request that you are making? I can try to reproduce it on my end, as with a plain Laravel install + Passport I am unable to reproduce that problem.
using the FoF/Passport package I managed to fix the access_token issue ( somehow ) - it was a misconfiguration in config/auth.php
Now I'm getting the following: UnexpectedValueException: Invalid response received from Authorization Server. Expected JSON.
Is there a way to capture this? Please let me know.
Hey!
I've never used that package so not 100% sure what might be causing this :/ also not sure if the package is still actively maintained.
I can see that you've actually already raised an issue with them here which would have been my suggestion as well!