{"id":75,"date":"2020-01-08T19:50:57","date_gmt":"2020-01-08T19:50:57","guid":{"rendered":"http:\/\/naveedulhaq.com\/?p=75"},"modified":"2021-01-24T20:12:50","modified_gmt":"2021-01-24T20:12:50","slug":"net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model","status":"publish","type":"post","link":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/","title":{"rendered":".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model"},"content":{"rendered":"\n<p>Recently I come across a requirement to create .NET Core Web API using JWT (JSON Web Token) authentication. I have used ASP.NET identity to provide a role-based authentication model.  I have used .NET core 3.x to create this example.<\/p>\n\n\n\n<p>For the sake of simplicity, I have used the default .NET Core project template to create a simple project. <\/p>\n\n\n\n<p>First of all, I have created a new project using the ASP.NET Core Web Application template.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1016\" height=\"672\" src=\"http:\/\/naveedu.sg-host.com\/wp-content\/uploads\/2020\/01\/aspnet-core-web-app-template.png\" loading=\"lazy\" alt=\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model\" class=\"wp-image-84\" srcset=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/aspnet-core-web-app-template.png 1016w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/aspnet-core-web-app-template-300x198.png 300w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/aspnet-core-web-app-template-768x508.png 768w\" sizes=\"auto, (max-width: 1016px) 100vw, 1016px\" \/><\/figure>\n\n\n\n<p>Select the project location<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1017\" height=\"677\" src=\"http:\/\/naveedu.sg-host.com\/wp-content\/uploads\/2020\/01\/select-project.png\" loading=\"lazy\" alt=\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model\" class=\"wp-image-86\" srcset=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/select-project.png 1017w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/select-project-300x200.png 300w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/select-project-768x511.png 768w\" sizes=\"auto, (max-width: 1017px) 100vw, 1017px\" \/><\/figure>\n\n\n\n<p>Select the project template as &#8220;Web Application&#8221;. Select Authentication to &#8220;Individual user &#8211; Store in Application&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1018\" height=\"699\" src=\"http:\/\/naveedu.sg-host.com\/wp-content\/uploads\/2020\/01\/web-api-template.png\" loading=\"lazy\" alt=\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model\" class=\"wp-image-87\" srcset=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/web-api-template.png 1018w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/web-api-template-300x206.png 300w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/web-api-template-768x527.png 768w\" sizes=\"auto, (max-width: 1018px) 100vw, 1018px\" \/><\/figure>\n\n\n\n<p>Now Visual Studio will create a new project with ASP.NET core identity authentication model. User accounts along with claims are stored in the database. If you run this project you will have the website with login and register functionality. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"347\" src=\"http:\/\/naveedu.sg-host.com\/wp-content\/uploads\/2020\/01\/home-page-1024x347.png\" loading=\"lazy\" alt=\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model\" class=\"wp-image-88\" srcset=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/home-page-1024x347.png 1024w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/home-page-300x102.png 300w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/home-page-768x261.png 768w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/home-page.png 1173w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now the next step is to create a Web API that uses the same users and generates a unique JWT token for authorization. <\/p>\n\n\n\n<p>Create Login model to use for input parameters for API methods<\/p>\n\n\n\n<pre><code>public class LoginModel\n    {\n\n        &#91;Required(ErrorMessage = \"Email is required\")]\n        public string Email { get; set; }\n\n        &#91;Required(ErrorMessage = \"Password is required\")]\n        public string Password { get; set; }\n    }<\/code><\/pre>\n\n\n\n<p>I have created a new controller in the Controllers folder with the name &#8220;AuthController&#8221; and created a Login method in this controller. The purpose of this method is; when an API client provides a user name and password to the method this method will generate a token. see the following code snippet &#8230;<\/p>\n\n\n\n<pre><code>&#91;ApiController]\n    &#91;Route(\"Api\/&#91;controller]\")]\n    public class AuthController : Controller\n    {\n        public class AuthenticationController : Controller\n        {\n            private UserManager&lt;IdentityUser&gt; _userManager;\n\n            \/\/private readonly IEmailSender _emailSender; UnComment if you want to add Email Verification also.\n\n            public AuthenticationController(\n                UserManager&lt;IdentityUser&gt; userManager)\n            {\n                _userManager = userManager;\n\n            }\n\n            &#91;HttpPost]\n            &#91;Route(\"Login\")]\n            public async Task&lt;IActionResult&gt; Login(&#91;FromBody] LoginModel model)\n            {\n                var user = await _userManager.FindByEmailAsync(model.Email);\n                if (user != null &amp;&amp; await _userManager.CheckPasswordAsync(user, model.Password))\n                {\n                    var tokenHandler = new JwtSecurityTokenHandler();\n\n                    var tokenDescriptor = new SecurityTokenDescriptor\n                    {\n                        Subject = new ClaimsIdentity(new Claim&#91;]{\n                    new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),\n                    new Claim(ClaimTypes.Name, user.Email)\n\n                }),\n                        Issuer = \"https:\/\/yourhostname.com\",\n                        Audience = \"https:\/\/yourhostname.com\",\n                        Expires = DateTime.Now.AddDays(1),\n                        SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(\"Key-From-Appsettings\")), SecurityAlgorithms.HmacSha512Signature),\n                    };\n\n                    var token = tokenHandler.CreateToken(tokenDescriptor);\n                    return Ok(new\n                    {\n                        token = tokenHandler.WriteToken(token),\n                        expiration = token.ValidTo\n                    });\n                }\n                return Unauthorized();\n            }\n\n          \n\n        }\n    }<\/code><\/pre>\n\n\n\n<p>Now if you can access this API method through Postman. it will give you Jwt token like below<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"415\" src=\"http:\/\/naveedu.sg-host.com\/wp-content\/uploads\/2020\/01\/postman-call-1024x415.png\" loading=\"lazy\" alt=\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model\" class=\"wp-image-93\" srcset=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/postman-call-1024x415.png 1024w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/postman-call-300x121.png 300w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/postman-call-768x311.png 768w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/postman-call-1536x622.png 1536w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2020\/01\/postman-call.png 1593w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now you can use this token to access any secure API controller. An example of a secure controller is below.<\/p>\n\n\n\n<pre><code>&#91;Authorize(AuthenticationSchemes =\n        JwtBearerDefaults.AuthenticationScheme, Roles = \"ApiUser\")]\n    &#91;Route(\"Api\/&#91;controller]\")]\n    &#91;ApiController]\n    public class SecureController : ControllerBase\n    {\n        private readonly UserManager&lt;IdentityUser&gt; _userManager;\n\n        public SecureController(UserManager&lt;IdentityUser&gt; userManager)\n        {\n            _userManager = userManager;\n        }\n\n        &#91;HttpGet]\n        &#91;Route(\"GetUser\")]\n        public async Task&lt;IActionResult&gt; GetMessageAsync()\n        {\n            var user = await GetCurrentUserAsync();\n            if (user != null)\n            {\n                return Ok(user);\n\n            }\n            return BadRequest(\"Error\");\n        }\n\n        #region Helpers\n        private async Task&lt;IdentityUser&gt; GetCurrentUserAsync()\n        {\n            string userName = HttpContext.User.Identity.Name;\n            return await _userManager.FindByNameAsync(userName);\n        }\n        #endregion\n    }<\/code><\/pre>\n\n\n\n<p>The above example controller is only accessed by the user of the role &#8220;ApiUser&#8221;. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I come across a requirement to create .NET Core Web API using JWT (JSON Web Token) authentication. I have used ASP.NET identity to provide&#8230;<\/p>\n","protected":false},"author":1,"featured_media":72,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[11,16,15],"class_list":["post-75","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dot-net-core","tag-dot-net-core","tag-jwt","tag-webapi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>.NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - Naveed Ul-Haq&#039;s blog<\/title>\n<meta name=\"description\" content=\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - .NET - Naveed Ul-Haq&#039;s blog\" \/>\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.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"og:description\" content=\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - .NET - Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/\" \/>\n<meta property=\"og:site_name\" content=\"Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-08T19:50:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-01-24T20:12:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2019\/04\/240px-.NET_Core_Logo.svg_.png\" \/>\n\t<meta property=\"og:image:width\" content=\"240\" \/>\n\t<meta property=\"og:image:height\" content=\"240\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Naveed Ul-Haq\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Naveed Ul-Haq\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated 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.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/\"},\"author\":{\"name\":\"Naveed Ul-Haq\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\"},\"headline\":\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model\",\"datePublished\":\"2020-01-08T19:50:57+00:00\",\"dateModified\":\"2021-01-24T20:12:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/\"},\"wordCount\":288,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\"},\"image\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2019\\\/04\\\/240px-.NET_Core_Logo.svg_.png\",\"keywords\":[\".net core\",\"Jwt\",\"Webapi\"],\"articleSection\":[\".NET\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/\",\"name\":\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - Naveed Ul-Haq&#039;s blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2019\\\/04\\\/240px-.NET_Core_Logo.svg_.png\",\"datePublished\":\"2020-01-08T19:50:57+00:00\",\"dateModified\":\"2021-01-24T20:12:50+00:00\",\"description\":\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - .NET - Naveed Ul-Haq&#039;s blog\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2019\\\/04\\\/240px-.NET_Core_Logo.svg_.png\",\"contentUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2019\\\/04\\\/240px-.NET_Core_Logo.svg_.png\",\"width\":240,\"height\":240,\"caption\":\".net core\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.naveedulhaq.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#website\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/\",\"name\":\"Naveed Ul-Haq's blog\",\"description\":\"AI, Optimizely, Azure &amp; more\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.naveedulhaq.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\",\"name\":\"Naveed Ul-Haq\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"caption\":\"Naveed Ul-Haq\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\"},\"description\":\"I lead engineering delivery teams for digital commerce and digital experience platforms, combining hands-on architecture experience with strong delivery governance. Over 20+ years, I\u2019ve built and led cross\u2011functional teams (engineering, BA, QA) delivering modern cloud solutions on Azure, microservices, APIs and eCommerce\\\/CMS platforms. My recent focus includes AI-enabled commerce automation: product ingestion and enrichment workflows, content optimisation for SEO and shopping feeds, and agentic tooling to improve marketing and accessibility workflows. I\u2019m passionate about building high-performing teams, establishing quality\\\/release standards, and delivering measurable outcomes across performance, reliability, and speed of change.\",\"sameAs\":[\"https:\\\/\\\/www.naveedulhaq.com\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/naveedulhaq\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - Naveed Ul-Haq&#039;s blog","description":".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - .NET - Naveed Ul-Haq&#039;s blog","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.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/","og_locale":"en_GB","og_type":"article","og_title":".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - Naveed Ul-Haq&#039;s blog","og_description":".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - .NET - Naveed Ul-Haq&#039;s blog","og_url":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/","og_site_name":"Naveed Ul-Haq&#039;s blog","article_published_time":"2020-01-08T19:50:57+00:00","article_modified_time":"2021-01-24T20:12:50+00:00","og_image":[{"width":240,"height":240,"url":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2019\/04\/240px-.NET_Core_Logo.svg_.png","type":"image\/png"}],"author":"Naveed Ul-Haq","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Naveed Ul-Haq","Estimated reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/#article","isPartOf":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/"},"author":{"name":"Naveed Ul-Haq","@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9"},"headline":".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model","datePublished":"2020-01-08T19:50:57+00:00","dateModified":"2021-01-24T20:12:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/"},"wordCount":288,"commentCount":0,"publisher":{"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9"},"image":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/#primaryimage"},"thumbnailUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2019\/04\/240px-.NET_Core_Logo.svg_.png","keywords":[".net core","Jwt","Webapi"],"articleSection":[".NET"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/","url":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/","name":".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - Naveed Ul-Haq&#039;s blog","isPartOf":{"@id":"https:\/\/www.naveedulhaq.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/#primaryimage"},"image":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/#primaryimage"},"thumbnailUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2019\/04\/240px-.NET_Core_Logo.svg_.png","datePublished":"2020-01-08T19:50:57+00:00","dateModified":"2021-01-24T20:12:50+00:00","description":".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model - .NET - Naveed Ul-Haq&#039;s blog","breadcrumb":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/#primaryimage","url":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2019\/04\/240px-.NET_Core_Logo.svg_.png","contentUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2019\/04\/240px-.NET_Core_Logo.svg_.png","width":240,"height":240,"caption":".net core"},{"@type":"BreadcrumbList","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/net-core-web-api-jwt-json-web-token-authentication-with-asp-net-identity-model\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.naveedulhaq.com\/"},{"@type":"ListItem","position":2,"name":".NET Core Web API Jwt (JSON Web Token) Authentication with ASP.NET identity model"}]},{"@type":"WebSite","@id":"https:\/\/www.naveedulhaq.com\/#website","url":"https:\/\/www.naveedulhaq.com\/","name":"Naveed Ul-Haq's blog","description":"AI, Optimizely, Azure &amp; more","publisher":{"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.naveedulhaq.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9","name":"Naveed Ul-Haq","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","caption":"Naveed Ul-Haq"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g"},"description":"I lead engineering delivery teams for digital commerce and digital experience platforms, combining hands-on architecture experience with strong delivery governance. Over 20+ years, I\u2019ve built and led cross\u2011functional teams (engineering, BA, QA) delivering modern cloud solutions on Azure, microservices, APIs and eCommerce\/CMS platforms. My recent focus includes AI-enabled commerce automation: product ingestion and enrichment workflows, content optimisation for SEO and shopping feeds, and agentic tooling to improve marketing and accessibility workflows. I\u2019m passionate about building high-performing teams, establishing quality\/release standards, and delivering measurable outcomes across performance, reliability, and speed of change.","sameAs":["https:\/\/www.naveedulhaq.com","https:\/\/www.linkedin.com\/in\/naveedulhaq\/"]}]}},"_links":{"self":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":0,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/media\/72"}],"wp:attachment":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}