Passport Version: ^10.1
Laravel Version: 8.77.1
PHP Version: 8.0.9
Database Driver & Version: mysql 8.0.27
I can not get access token. when I call it manual by curl it get this response.
this host name is generate inside the docker container
I’m test 192.168.224.6 ip of docker container but it also not work
/var/www/html # curl --location --request POST 'http://docker-nginx/oauth/token' > --header 'Accept: application/json' > --form 'grant_type="password"' > --form 'client_id="4"' > --form 'client_secret="hZJ33buLLIe3ekqe1dv62tn6RkBFMp59fZjeBgPW"' > --form 'username="creatrre@gmail.org"' > --form 'password="creatrre@gmail.com"' > --form 'scope=""' { "message": "Bad hostname provided.", "exception": "Symfony\Component\HttpKernel\Exception\NotFoundHttpException", "file": "/var/www/html/releases/20211223205412/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php", "line": 391, "trace": [ { "file": "/var/www/html/releases/20211223205412/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php", "line": 332, "function": "prepareException", "class": "Illuminate\Foundation\Exceptions\Handler", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/app/Exceptions/Handler.php", "line": 97, "function": "render", "class": "Illuminate\Foundation\Exceptions\Handler", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 51, "function": "render", "class": "App\Exceptions\Handler", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 172, "function": "handleException", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/vendor/fideloper/proxy/src/TrustProxies.php", "line": 57, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Fideloper\Proxy\TrustProxies", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustHosts.php", "line": 48, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\Http\Middleware\TrustHosts", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 103, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 142, "function": "then", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 111, "function": "sendRequestThroughRouter", "class": "Illuminate\Foundation\Http\Kernel", "type": "->" }, { "file": "/var/www/html/releases/20211223205412/public/index.php", "line": 52, "function": "handle", "class": "Illuminate\Foundation\Http\Kernel", "type": "->" } ] /var/www/html #
Advertisement
Answer
if you don’t use any prefix for passport, it is better to use
APP URL instead docker container name http://docker-nginx
http://docker-nginx/oauth/token wrong
env(‘APP_URL’)/oauth/token correct