Open virajkaulkar opened 6 years ago
same problem.
Hi, I have the same problem as {'error': 'token_not_provided'}. I'm using Laravel 5.6 with "tymon / jwt-auth": "^ 0.5.12", everything worked fine on my localhost, but when I uploaded it to the hosting now I get the error mentioned above. In the headers I am sending the token, and I already change the .htaccess as indicated in others thread, but even so it does not work for me. Here are the headlines: `Response Headers
Access-Control-Allow-Origin: https://www.********.com Access-Control-Expose-Headers: Authorization Cache-Control: no-cache, private Connection: close Content-Type: application/json Date: Sat, 21 Jul 2018 03:20:18 GMT Server: Apache Transfer-Encoding: chunked Vary: Origin X-Powered-By: PHP/7.2.7 X-RateLimit-Limit: 60 X-RateLimit-Remaining: 58
Request headers
Accept: application/json Accept-Encoding: gzip, deflate, br Accept-Language: es-CO,en-US;q=0.7,en;q=0.3 Access-Control-Allow-Headers: Origin, X-Requested-With, Cont…t-Type, Accept, Authorization Authorization: Bearer eyJ0....... Cache-Control: no-cache Connection: keep-alive Content-Type: application/json Host: **.com Origin: https://www.**********.com Pragma: no-cache Referer: https://www.********.com/FrontAppDomicilio/ User-Agent: Mozilla/5.0 (X11; Linux x86_64…) Gecko/20100101 Firefox/61.0`
Got the same problem, any fix?
You can try this in app/exceptions/Handler.php
Make sure you use these on top
use Tymon\JWTAuth\Exceptions\TokenExpiredException;
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
use Tymon\JWTAuth\Exceptions\TokenBlacklistedException;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
And Inside the render method
public function render($request, Exception $exception)
{
// detect instance
if ($exception instanceof UnauthorizedHttpException) {
// detect previous instance
if ($exception->getPrevious() instanceof TokenExpiredException) {
return response()->json(['error' => 'TOKEN_EXPIRED'], $exception->getStatusCode());
} else if ($exception->getPrevious() instanceof TokenInvalidException) {
return response()->json(['error' => 'TOKEN_INVALID'], $exception->getStatusCode());
} else if ($exception->getPrevious() instanceof TokenBlacklistedException) {
return response()->json(['error' => 'TOKEN_BLACKLISTED'], $exception->getStatusCode());
} else {
return response()->json(['error' => "UNAUTHORIZED_REQUEST"], 401);
}
}
return parent::render($request, $exception);
}
its giving error UNAUTHORIZED_REQUEST
very good
Simply, Change the request type to "post" and pass the "{token: (jwt auth token)}"
thanks its working but its getting as a parameter not header?
its giving error UNAUTHORIZED_REQUEST
add params ?token="your_api_key"
Hi, my problem was, that Apache by default removes Auth header :man_facepalming:. Found fix here: https://github.com/tymondesigns/jwt-auth/issues/81#issuecomment-91782074
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Subject of the issue
UnauthorizedHttpException Not Handled
Your environment
Steps to reproduce
Once I use middleware to guard my routes its throwing exception without handling it. It's Showing correct message but exception is not handled.
Expected behaviour
Exception should be handled and it should return error message in JSON format
Actual behaviour
It's throwing an UnauthorizedHttpException