Предварительно создайте пользователя с ролью ROLE_USER и следующими данными:
email: [email protected]
password: 123456
Пример запроса на получение JWT токена:
curl -X POST -H "Content-Type: application/json" http://localhost:8889/api/auth/v1/token -d '{"email":"[email protected]","password":"123456"}'
{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2ODY1OTQ4OTgsImV4cCI6MTY4Njk1NDg5OCwicm9sZXMiOlsiUk9MRV9VU0VSIl0sImVtYWlsIjoiZW1haWxAdGVzdC5jb20ifQ.S9Yf-rb1QEjlAD1v8Y06FVYPjsiiNxLl74EZ3aCMZktye3ZR3ZS2gEVvcsD1iBr98I8brSb0lobcIS2ehpceqDoGLNSJLkq12M9yKnV8slZ37CEiaLRUT_7t2R6NgNJGM6gJfxYjTaY-Jbfhj3qqnvSlQo664Hx2xYQFyw1fdgQnIyrI_O4MUHnjMPQoZdoztwNEli6Y4vPQp35rYJ6dddZs6cVoBPoBZSdbKWC_57hwst2M8nqGwLIgcfRAWbaJ7-M8U-fX8txh5rvliWyQIBDOWsruWx16HSotxD8RYgbsJcYXzKv8Ca3UzdXEI_kICwU2rZDV72G28yle7XRlkZXx5ofeE8aKEAto9NFpr1GnleurEDEUFQI6j1jP_msbDx0St5OSd1MX7qjpnlw3TNfcP_LwNs2__zyS-QwOEeovrnM6AGu7R3F1jSH2BpgvdlEo97IZepvs7oyIZG8_iDly-KEySePGoTvDHdLRPvRX1TdWkB5jFAZHedPePfgCsxdZ_7ZByiDCtYHNzAJkCjL48N0oLTy_keFDxERwSUiwdXFmiTPonYhZHR-jI55MFyzzV6DzwmDl1UFgiyux3x4C52BoObYPqVTyHandRBh6nuRNsX9xb_ifnK5WeDs4-49RWqUKa5lCAxHdoY73DlQvmYQXkOQ8vfr9KDby0wY","refreshToken":"ae70097fda5802da23c5eb2d2e2cb099fdd1894f6dad58b3e108abe57f4b7307939969f1cf8b2a6895e85f6052689b063b35859213eacbbb0fed5280fd7205e6"}
Пример запроса получения информации об авторизованном пользователе с использованием JWT токена:
$ curl -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2ODY1OTM0ODYsImV4cCI6MTY4Njk1MzQ4Niwicm9sZXMiOlsiUk9MRV9VU0VSIl0sImVtYWlsIjoiZW1haWxAdGVzdC5jb20ifQ.if-HuqmCPwRN9wDYaAY8om4E88FlreMiImVVuGfGveHqv4Lb_75Edu9XhE7CogZmmHeYJ7sVtCrlhfffIPqhavzp3mEI7Fn8LeJojpQmvnGtKxdWYdwmgSGhwGcL9yviq4kpD46Ou40zFm6m2dFEKnLVawUuB14tmkiVrYqUVTnej1LGZO-Jpaw4_fN7gJY6r5qhjVBW1BmusIr5hSYxFQMRuwjLCFMeNacps-ggbbi5wZ__a5tH_0hGCjHK_l0UVGW7FXeb9EvdxCgNm9IdzJhdtBfhjjKpLvutbtHh8TYYIVoR-pia7SLmdhFdCZhZhFNslu6vJ5v6I6GK0J5DA6MYaLU5wOG9VMeIztUCREc7PqWP68upzC0Pj8XdzxeTHog3syltn0slnzYT835iVJxyQXBQWckJ90Gs8x3lAQHlFghxtW1X21EBiVg8vuGohVVzd-bSNCKG2sGO1XOv-NLTKWeh4boQjP6LkNliqvD7nzHZUSmgyL6klmKnXBJhX8rJmWVdbp_MGWdPOjIp8rZ50-pRNANm-yTCZvn_2BIv1QL9c5m_blC_eV5hTBQ1n3DQd2yRmqRk6eVIqktaG9XMtYaDLcdHMScaTh90pHW0mivxj8kmWJlgXyHPu9Ad8vlAtwOlUVaOKQVMwqNtsYNVrjJeGPF4s3a9TsBVBGs" http://localhost:8889/api/users/me
{"ulid":"01H2E14XMB1GCJ0G25EEGB73HY","email":"[email protected]"}%
Пример запроса обновления JWT токена:
curl -X POST -H "Content-Type: application/json" http://localhost:8889/api/auth/v1/refresh-token -d '{"refreshToken":"16bc192a6614782aeaba07cfad285b2fc6bd5dc818c1ac41080155ce431e86fc358322041daf5a6cbe0b29d32c8651af7a84bd8b3432682d6b0e455668da1539"}'
{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2ODY1OTQ4NTIsImV4cCI6MTY4Njk1NDg1Miwicm9sZXMiOlsiUk9MRV9VU0VSIl0sImVtYWlsIjoiZW1haWxAdGVzdC5jb20ifQ.AhRCgf6cCwAtofjfPSiVOAYW_gu6i1gTiskwRMOw3XqkjSYyY8-a0bUfc35I1tEdgIeYDmmr2h0OeOMweWdO3S6SGVawQvpN2Zx1Xp1pUeZm06xLXfFRh2Ycnz1Atgb_E5FxGmhtmNBXDglwg_Rlp5gR5ZSYx2-3upaITIJnOY3ABltcoVcumS9mfWM5G_XonEC03Bw-e560I2K_7lFCR8zyiARHs620Pc6lNiNZo0fItiYgYpiO44mXge1FeA_GcBI4g690-JTAlSlPZaoqi3xIsItDrOPewWLqZasX94ZuIJctTjPNzbfaNGji6vlaIVkL-XRkQC1MM1nkAuUqs39CWN2DdTQe1aX6LragbViaFtwK2452ka0z0aPUNAIhNI9x5SqPw5_5lk63IGV6JoqsgpiwrxQdtvowgNLxtecWzw73FCu9UNj-rvOaY-HdDUwgZo5ZZ2ery9vGQM5Tb3Sjlnl6HbsAGgXB5KAtGI9oxcDxkk8ux5NUIzEYZtm8Qurf1OBpXBgj5QRI66N7eld8bROgHe6tIIxONPAl3ETEkjVo_BvyZGJjNWsKxkrbLy9qZ8ND8VLBbvNRBXx5Fa9rgEMEwzzmM6pJ_UFlhOsGY97zLeQp60KVL-p6ci1WxIQ3vwKFVev4c1i3lARYf0r8sJ887tufoxjn84S7DYU","refreshToken":"16bc192a6614782aeaba07cfad285b2fc6bd5dc818c1ac41080155ce431e86fc358322041daf5a6cbe0b29d32c8651af7a84bd8b3432682d6b0e455668da1539"}