{"action":"closed","issue":{"url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/939","repository_url":"https://api.github.com/repos/tymondesigns/jwt-auth","labels_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/939/labels{/name}","comments_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/939/comments","events_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/939/events","html_url":"https://github.com/tymondesigns/jwt-auth/issues/939","id":197441995,"number":939,"title":"Refresh token is the same old token in blacklist","user":{"login":"devtosystems","id":4691768,"avatar_url":"https://avatars.githubusercontent.com/u/4691768?v=3","gravatar_id":"","url":"https://api.github.com/users/devtosystems","html_url":"https://github.com/devtosystems","followers_url":"https://api.github.com/users/devtosystems/followers","following_url":"https://api.github.com/users/devtosystems/following{/other_user}","gists_url":"https://api.github.com/users/devtosystems/gists{/gist_id}","starred_url":"https://api.github.com/users/devtosystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devtosystems/subscriptions","organizations_url":"https://api.github.com/users/devtosystems/orgs","repos_url":"https://api.github.com/users/devtosystems/repos","events_url":"https://api.github.com/users/devtosystems/events{/privacy}","received_events_url":"https://api.github.com/users/devtosystems/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-24T01:22:30Z","updated_at":"2016-12-24T14:39:26Z","closed_at":"2016-12-24T14:39:26Z","body":"I have a question about jwt-auth api route.\r\n\r\nReference issue `Using guard with laravel 5.3.x` no. #860 \r\n\r\nGET /myproject/public/api/user\r\n\r\nThe code below return \"unauthorized 401\" code:\r\n\r\n```php\r\nRoute::get('/user', 'UsersController@info', [\r\n    'request' => Request::capture()\r\n])->middleware(['jwt.auth']);\r\n...\r\n```\r\n\r\noutput:\r\n\r\n```\r\nUnauthorizedHttpException in BaseMiddleware.php line 71:\r\nThe token has been blacklisted\r\n```\r\n\r\nIs it correct after receiving 401 code I invoke the method of updating the user's expired token?\r\n\r\nroute:\r\n\r\n```\r\nGET /myproject/public/api/refresh-token HTTP/1.1\r\nAccept:          application/json\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4,cs;q=0.2,es;q=0.2,ru;q=0.2,gl;q=0.2,zh-TW;q=0.2,zh;q=0.2\r\nAuthorization:   Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vcHJvamVjdHMuZGV2L2xhcmF2ZWwvYXBpLmJlc3RkZXN0aW55L3B1YmxpYy9hcGkvbG9naW4iLCJpYXQiOjE0ODI1Mzc1NzIsImV4cCI6MTQ4MjU0MTE3MiwibmJmIjoxNDgyNTM3NTcyLCJqdGkiOiJQYzJwSFVackdnRmNGNlRFIiwic3ViIjozLCJGb3JtQXV0aCI6eyJpZCI6MywiZW1haWwiOiJmcmFuY2lzLTAzQHRvc3lzdGVtcy5uZXQiLCJjcmVhdGVkQXQiOiIyMDE2LTEyLTIzIDE4OjI3OjAwLTAyIiwibGFzdEFjY2VzcyI6IjIwMTYtMTItMjMgMTg6Mjc6MDAtMDIifX0.UBlx-19EJCZ0d0CPJWzfxIqWocHtBCDf3_X7EQe1q4w\r\n```\r\n\r\n```php\r\n...\r\nRoute::get('/refresh-token', function (Request $request) {\r\n    return $request;\r\n})->middleware('jwt.refresh');\r\n...\r\n```\r\n\r\n\\App\\Http\\Middleware\\RefreshToken\r\n\r\n```php\r\n...\r\npublic function handle($request, \\Closure $next)\r\n    {\r\n        $response = $next($request);\r\n\r\n        $auth = new AuthManager($request, HttpManager::getAuthType($request));\r\n        $this->auth = $auth->getGuard();\r\n\r\n        try {\r\n            $newToken = $this->auth->setRequest($request)->parseToken()->refresh();\r\n        } catch (TokenExpiredException $e) {\r\n            return response()->json(['tymon.jwt.expired'], $e->getCode(), [$e]);\r\n        } catch (JWTException $e) {\r\n            return response()->json(['tymon.jwt.invalid'], $e->getCode(), [$e]);\r\n        }\r\n\r\n        // send the refreshed token back to the client\r\n        $response->headers->set('Authorization', 'Bearer '.$newToken);\r\n\r\n        return $response;\r\n    }\r\n...\r\n```\r\n\r\noutput below:\r\n\r\n```\r\nGET /myproject/public/api/refresh-token HTTP/1.1\r\nAccept:          application/json\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4,cs;q=0.2,es;q=0.2,ru;q=0.2,gl;q=0.2,zh-TW;q=0.2,zh;q=0.2\r\nAuthorization:   Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vcHJvamVjdHMuZGV2L2xhcmF2ZWwvYXBpLmJlc3RkZXN0aW55L3B1YmxpYy9hcGkvbG9naW4iLCJpYXQiOjE0ODI1Mzc1NzIsImV4cCI6MTQ4MjU0MTE3MiwibmJmIjoxNDgyNTM3NTcyLCJqdGkiOiJQYzJwSFVackdnRmNGNlRFIiwic3ViIjozLCJGb3JtQXV0aCI6eyJpZCI6MywiZW1haWwiOiJmcmFuY2lzLTAzQHRvc3lzdGVtcy5uZXQiLCJjcmVhdGVkQXQiOiIyMDE2LTEyLTIzIDE4OjI3OjAwLTAyIiwibGFzdEFjY2VzcyI6IjIwMTYtMTItMjMgMTg6Mjc6MDAtMDIifX0.UBlx-19EJCZ0d0CPJWzfxIqWocHtBCDf3_X7EQe1q4w\r\nCache-Control:   no-cache\r\nConnection:      keep-alive\r\nCookie:          mage-cache-storage=%7B%7D; mage-cache-storage-section-invalidation=%7B%7D; mage-cache-sessid=true\r\nDnt:             1\r\nHost:            projects.dev\r\nUser-Agent:      Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36\r\n```\r\n\r\nThe token refresh is `the same`, but invalidated the previous token. :o \r\n\r\nMaybe the error is here \r\n\r\n```php\r\n...\r\n$newToken = $this->auth->setRequest($request)->parseToken()->refresh();\r\n...```"}}
{"actor":{"display_login":"devtosystems"}}