{"id":401,"date":"2021-05-02T17:54:49","date_gmt":"2021-05-02T17:54:49","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/spring-boot\/?p=401"},"modified":"2021-05-03T06:54:36","modified_gmt":"2021-05-03T06:54:36","slug":"jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/","title":{"rendered":"JWT(JSON Web Token) With SpringBoot &#8211; Step by Step Tutorial &#8211; Part 1"},"content":{"rendered":"<p>In this tutorial, you will learn how to implement JWT(JSON Web Token) authorization with Spring Boot. It would be a step by step tutorial for beginners as well as intermediates.<\/p>\n<p><strong>Step 1<\/strong> &#8211; Create and new spring application adding the following dependencies:<\/p>\n<ul>\n<li>Spring-Web<\/li>\n<li>Spring Security<\/li>\n<li>Lombok<\/li>\n<\/ul>\n<p><strong>Step 2<\/strong> &#8211; Create class that extends the <em>WebSecurityConfigurerAdapter<\/em> and override the configure method (<em>configure(AuthenticationManagerBuilder auth)<\/em>). Annotate this class with @Configuration and @EnableWebSecurity<\/p>\n<p><strong>Step 3<\/strong> &#8211; Create a class named <em>MyUserDetailsService<\/em> that implements <em>UserDetailsService<\/em>. You can put this in the services package. In this class, implement the <em>loadUserByUsername()<\/em> method. This method should return a hardcoded user. This class should be annotated with the <em>@Service<\/em> annotation. The <em>MyUserDetailsService<\/em> class is given below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@Service<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">MyUserDetailsService<\/span> <span style=\"color: #008800; font-weight: bold;\">implements<\/span> UserDetailsService <span style=\"color: #333333;\">{<\/span>\r\n    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span>\r\n    <span style=\"color: #008800; font-weight: bold;\">public<\/span> UserDetails <span style=\"color: #0066bb; font-weight: bold;\">loadUserByUsername<\/span><span style=\"color: #333333;\">(<\/span>String s<span style=\"color: #333333;\">)<\/span> <span style=\"color: #008800; font-weight: bold;\">throws<\/span> UsernameNotFoundException <span style=\"color: #333333;\">{<\/span>\r\n        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> <span style=\"color: #0066bb; font-weight: bold;\">User<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"admin\"<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"password\"<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> ArrayList<span style=\"color: #333333;\">&lt;&gt;());<\/span>\r\n    <span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Step 4<\/strong> &#8211; Autowire the MyUserDetailsService into the SecurityConfigurer class. Then override the configure method and change the parameter to AuthenticationManagerBuilder. Next, in the configure method, set the userDetailsService of the AuthenticationManagerBuilder to the MyUserDetailsService you autowired. See the code below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@Override<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">protected<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">configure<\/span><span style=\"color: #333333;\">(<\/span>AuthenticationManagerBuilder auth<span style=\"color: #333333;\">)<\/span> <span style=\"color: #008800; font-weight: bold;\">throws<\/span> Exception <span style=\"color: #333333;\">{<\/span>\r\n    auth<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">userDetailsService<\/span><span style=\"color: #333333;\">(<\/span>myUserDetailsService<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Step 5<\/strong> &#8211; Create a password encoder bean in the SecurityConfigurer class like so:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">    <span style=\"color: #555555; font-weight: bold;\">@Bean<\/span>\r\n    <span style=\"color: #008800; font-weight: bold;\">public<\/span> PasswordEncoder <span style=\"color: #0066bb; font-weight: bold;\">passwordEncoder<\/span><span style=\"color: #333333;\">(){<\/span>\r\n        <span style=\"color: #008800; font-weight: bold;\">return<\/span> NoOpPasswordEncoder<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getInstance<\/span><span style=\"color: #333333;\">();<\/span>\r\n    <span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Step 6<\/strong>: Add the <strong><em>jjwt<\/em><\/strong> and <strong><em>jaxb<\/em><\/strong> dependencies to your pom.xml<\/p>\n<p><strong>Step 7<\/strong>: Create a utility class inside a util package. This class should be a component and should implement Serializable interface. I call it <em>JwtUtility.java<\/em>. This class contains code for jwt processing. The content of quite verbose. <a href=\"https:\/\/drive.google.com\/file\/d\/1Ki782Sldlpq_1wo-dUP70qvo-acRC97h\/view?usp=sharing\" target=\"_blank\" rel=\"noopener\">So simply copy it from this link<\/a>.<\/p>\n<p>Now we need to create an authenticate api. This would take a username and password and return a JWT.<\/p>\n<p><strong>Step 8<\/strong> &#8211; First create two classes: JwtRequest and JwtResponse inside a model package. The Request class would have a username and password fields while the Response class would have jwt field.<\/p>\n<p><strong>Step 9 (there&#8217;ll be error!)<\/strong>\u00a0&#8211; In the <em>HomeResource<\/em> class, create the authentication endpoint with PostMapping of <em>\/authenticate<\/em>. To do that, you need to first autowire the <em>AuthenticationManager<\/em>, <em>JwtUtility<\/em> and the <em>MyUserDetailsService<\/em> into the class.<\/p>\n<p>The authenticate method is given below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@PostMapping<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"\/authenticate\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> JwtResponse <span style=\"color: #0066bb; font-weight: bold;\">authenticate<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #555555; font-weight: bold;\">@RequestBody<\/span> JwtRequest jwtRequest<span style=\"color: #333333;\">)<\/span> <span style=\"color: #008800; font-weight: bold;\">throws<\/span> Exception <span style=\"color: #333333;\">{<\/span>\r\n\r\n    <span style=\"color: #008800; font-weight: bold;\">try<\/span><span style=\"color: #333333;\">{<\/span>\r\n        authenticationManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">authenticate<\/span><span style=\"color: #333333;\">(<\/span>\r\n                <span style=\"color: #008800; font-weight: bold;\">new<\/span> <span style=\"color: #0066bb; font-weight: bold;\">UsernamePasswordAuthenticationToken<\/span><span style=\"color: #333333;\">(<\/span>\r\n                        jwtRequest<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getUsername<\/span><span style=\"color: #333333;\">(),<\/span>\r\n                        jwtRequest<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getPassword<\/span><span style=\"color: #333333;\">()<\/span>\r\n                <span style=\"color: #333333;\">)<\/span>\r\n        <span style=\"color: #333333;\">);<\/span>\r\n    <span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">catch<\/span> <span style=\"color: #333333;\">(<\/span>BadCredentialsException e<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n        <span style=\"color: #008800; font-weight: bold;\">throw<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Exception<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Invalid Credentials\"<\/span><span style=\"color: #333333;\">,<\/span> e<span style=\"color: #333333;\">);<\/span>\r\n    <span style=\"color: #333333;\">}<\/span>\r\n\r\n    <span style=\"color: #008800; font-weight: bold;\">final<\/span> UserDetails userDetails\r\n            <span style=\"color: #333333;\">=<\/span> myUserDetailsService<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">loadUserByUsername<\/span><span style=\"color: #333333;\">(<\/span>jwtRequest<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getUsername<\/span><span style=\"color: #333333;\">());<\/span>\r\n\r\n    <span style=\"color: #008800; font-weight: bold;\">final<\/span> String token <span style=\"color: #333333;\">=<\/span>\r\n            jwtUtility<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">generateToken<\/span><span style=\"color: #333333;\">(<\/span>userDetails<span style=\"color: #333333;\">);<\/span>\r\n\r\n    <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> <span style=\"color: #0066bb; font-weight: bold;\">JwtResponse<\/span><span style=\"color: #333333;\">(<\/span>token<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Step 10<\/strong> &#8211; To clear the error from Step 9, you need to create the AuthenticationManager bean in the <em>WebConfigurer<\/em> class. This is given below:<br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@Override<\/span>\r\n<span style=\"color: #555555; font-weight: bold;\">@Bean<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> AuthenticationManager <span style=\"color: #0066bb; font-weight: bold;\">authenticationManagerBean<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #008800; font-weight: bold;\">throws<\/span> Exception <span style=\"color: #333333;\">{<\/span>\r\n    <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">super<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">authenticationManagerBean<\/span><span style=\"color: #333333;\">();<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Step 11<\/strong>\u00a0&#8211; Create the configuration to allow the \/authenticate endpoint without authentication. To do this, you need to override the <em>configure(HttpSecurity)<\/em> method in the <em>SecurityConfigurer<\/em> class.<\/p>\n<p>This is shown below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@Override<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">protected<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">configure<\/span><span style=\"color: #333333;\">(<\/span>HttpSecurity http<span style=\"color: #333333;\">)<\/span> <span style=\"color: #008800; font-weight: bold;\">throws<\/span> Exception <span style=\"color: #333333;\">{<\/span>\r\n    http<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">csrf<\/span><span style=\"color: #333333;\">().<\/span><span style=\"color: #0000cc;\">disable<\/span><span style=\"color: #333333;\">()<\/span>\r\n            <span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">authorizeRequests<\/span><span style=\"color: #333333;\">()<\/span>\r\n            <span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">antMatchers<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"\/authenticate\"<\/span><span style=\"color: #333333;\">).<\/span><span style=\"color: #0000cc;\">permitAll<\/span><span style=\"color: #333333;\">()<\/span>\r\n            <span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">anyRequest<\/span><span style=\"color: #333333;\">().<\/span><span style=\"color: #0000cc;\">authenticated<\/span><span style=\"color: #333333;\">();<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Step 12<\/strong> &#8211; Test the Application. Lauch the application, visit http:\/\/localhost:8080\/authenticate and send a post request with username and password in the body of the request. You&#8217;ll see that you will recieve the authentication token as a response.<\/p>\n<p>At this point, you have completed the first part. In Part 2, we would see how to use the token on subsequent requests using a Filter. Remember to watch the video on <a href=\"https:\/\/www.youtube.com\/c\/KindsonTheTechPro\" target=\"_blank\" rel=\"noopener\">my YouTube Channel<\/a>.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to implement JWT(JSON Web Token) authorization with Spring Boot. It would be a step by step tutorial for &hellip; <!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":404,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[45,46,44],"class_list":["post-401","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-boot-tutorials","tag-java","tag-json-web-token","tag-jwt"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JWT(JSON Web Token) With SpringBoot - Step by Step Tutorial - Part 1 - Learn Spring Boot<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will easily learn how to implement JWT(JSON Web Token) in Spring Boot step by step with source codes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JWT(JSON Web Token) With SpringBoot - Step by Step Tutorial - Part 1 - Learn Spring Boot\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will easily learn how to implement JWT(JSON Web Token) in Spring Boot step by step with source codes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn Spring Boot\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-02T17:54:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-03T06:54:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2021\/05\/JWT-Authentication-in-Spring-Boot.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"637\" \/>\n\t<meta property=\"og:image:height\" content=\"205\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"headline\":\"JWT(JSON Web Token) With SpringBoot &#8211; Step by Step Tutorial &#8211; Part 1\",\"datePublished\":\"2021-05-02T17:54:49+00:00\",\"dateModified\":\"2021-05-03T06:54:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/\"},\"wordCount\":462,\"commentCount\":2,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2021\\\/05\\\/JWT-Authentication-in-Spring-Boot.jpg\",\"keywords\":[\"Java\",\"JSON Web Token\",\"JWT\"],\"articleSection\":[\"Spring Boot Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/\",\"name\":\"JWT(JSON Web Token) With SpringBoot - Step by Step Tutorial - Part 1 - Learn Spring Boot\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2021\\\/05\\\/JWT-Authentication-in-Spring-Boot.jpg\",\"datePublished\":\"2021-05-02T17:54:49+00:00\",\"dateModified\":\"2021-05-03T06:54:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"description\":\"In this tutorial, you will easily learn how to implement JWT(JSON Web Token) in Spring Boot step by step with source codes.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2021\\\/05\\\/JWT-Authentication-in-Spring-Boot.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2021\\\/05\\\/JWT-Authentication-in-Spring-Boot.jpg\",\"width\":637,\"height\":205,\"caption\":\"JWT Authentication in Spring Boot\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JWT(JSON Web Token) With SpringBoot &#8211; Step by Step Tutorial &#8211; Part 1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/\",\"name\":\"Learn Spring Boot\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/author\\\/kindsonthegenius-3\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JWT(JSON Web Token) With SpringBoot - Step by Step Tutorial - Part 1 - Learn Spring Boot","description":"In this tutorial, you will easily learn how to implement JWT(JSON Web Token) in Spring Boot step by step with source codes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/","og_locale":"en_US","og_type":"article","og_title":"JWT(JSON Web Token) With SpringBoot - Step by Step Tutorial - Part 1 - Learn Spring Boot","og_description":"In this tutorial, you will easily learn how to implement JWT(JSON Web Token) in Spring Boot step by step with source codes.","og_url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/","og_site_name":"Learn Spring Boot","article_published_time":"2021-05-02T17:54:49+00:00","article_modified_time":"2021-05-03T06:54:36+00:00","og_image":[{"width":637,"height":205,"url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2021\/05\/JWT-Authentication-in-Spring-Boot.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"headline":"JWT(JSON Web Token) With SpringBoot &#8211; Step by Step Tutorial &#8211; Part 1","datePublished":"2021-05-02T17:54:49+00:00","dateModified":"2021-05-03T06:54:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/"},"wordCount":462,"commentCount":2,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2021\/05\/JWT-Authentication-in-Spring-Boot.jpg","keywords":["Java","JSON Web Token","JWT"],"articleSection":["Spring Boot Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/","name":"JWT(JSON Web Token) With SpringBoot - Step by Step Tutorial - Part 1 - Learn Spring Boot","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2021\/05\/JWT-Authentication-in-Spring-Boot.jpg","datePublished":"2021-05-02T17:54:49+00:00","dateModified":"2021-05-03T06:54:36+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"description":"In this tutorial, you will easily learn how to implement JWT(JSON Web Token) in Spring Boot step by step with source codes.","breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2021\/05\/JWT-Authentication-in-Spring-Boot.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2021\/05\/JWT-Authentication-in-Spring-Boot.jpg","width":637,"height":205,"caption":"JWT Authentication in Spring Boot"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/jwtjson-web-token-with-springboot-step-by-step-tutorial-part-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/spring-boot\/"},{"@type":"ListItem","position":2,"name":"JWT(JSON Web Token) With SpringBoot &#8211; Step by Step Tutorial &#8211; Part 1"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#website","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/","name":"Learn Spring Boot","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/spring-boot\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/author\/kindsonthegenius-3\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/comments?post=401"}],"version-history":[{"count":5,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/401\/revisions"}],"predecessor-version":[{"id":412,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/401\/revisions\/412"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/media\/404"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/media?parent=401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/categories?post=401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/tags?post=401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}