You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I followed the steps in the readme section, and it works. My only issue is that when the token is expired I get this error { "name": "Unauthorized", "message": "Your request was made with invalid credentials.", "code": 0, "status": 401, "type": "yii\\web\\UnauthorizedHttpException" }
I want to customize it to "token expired message" so in the frontend I can handle it and send a request to refresh the token.
do you any idea on how to achieve this?
The text was updated successfully, but these errors were encountered:
Hi @abdouTurki ,
by default exception is thrown by parent method handleFailure(). So you can extend JwtHttpBearerAuth and override it.
classMyJwtAuthextends \sizeg\jwt\JwtHttpBearerAuth
{
/** * {@inheritdoc} */publicfunctionhandleFailure($response)
{
// you can create any exception you wish and throw it here or customize responsethrownewUnauthorizedHttpException('token expired message');
}
}
I have the same problem, I want to handle the whole failed response.
{ "name": "Unauthorized", "message": "Your request was made with invalid credentials.", "code": 0, "status": 401, "type": "yii\\web\\UnauthorizedHttpException" }
But I want a custom response. something like below. { "status": "failed", "message": "Your message.", "data": [] }
I have checked the answer but don't get where to put this file.
class MyJwtAuth extends \sizeg\jwt\JwtHttpBearerAuth
{
/**
* {@inheritdoc}
*/
public function handleFailure($response)
{
// you can create any exception you wish and throw it here or customize response
throw new UnauthorizedHttpException('token expired message');
}
}
can you please let me know how to achieve a custom response?
Hi,
I followed the steps in the readme section, and it works. My only issue is that when the token is expired I get this error
{ "name": "Unauthorized", "message": "Your request was made with invalid credentials.", "code": 0, "status": 401, "type": "yii\\web\\UnauthorizedHttpException" }
I want to customize it to "token expired message" so in the frontend I can handle it and send a request to refresh the token.
do you any idea on how to achieve this?
The text was updated successfully, but these errors were encountered: