I'm using this library : Oauth2 PHP
Is there a way to modify the response when token is invalid or expired from codeigniter filter?
class OauthFilter implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
$oauth = new Oauth();
$request = Request::createFromGlobals();
$response = new Response();
if(!$oauth->server->verifyResourceRequest($request)){
$oauth->server->getResponse()->send();
die();
}
}
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
}
}
The default response was
{
"error": "invalid_token",
"error_description": "The access token provided is invalid"
}
I know that verifyResourceRequest also calls getAccessToken. When I tried it separately it returns null.
$oauth->server->getAccessTokenData($request,$response)